searchIndex method

Future<SearchIndexResponse> searchIndex({
  1. required String queryString,
  2. String? indexName,
  3. int? maxResults,
  4. String? nextToken,
  5. String? queryVersion,
})

Searches the specified index.

If a device has never connected to IoT Core or was disconnected for more than 1 hour before fleet indexing's thingConnectivityIndexingMode was enabled, the connectivity object for this device in the response will have the connected field set to false with no additional session details.

Requires permission to access the SearchIndex action.

May throw IndexNotReadyException. May throw InternalFailureException. May throw InvalidQueryException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException. May throw UnauthorizedException.

Parameter queryString : The search query string. For more information about the search query syntax, see Query syntax.

Parameter indexName : The search index name.

Parameter maxResults : The maximum number of results to return per page at one time. This maximum number cannot exceed 100. The response might contain fewer results but will never contain more. You can use nextToken to retrieve the next set of results until nextToken returns NULL.

Parameter nextToken : The token used to get the next set of results, or null if there are no additional results.

Parameter queryVersion : The query version.

Implementation

Future<SearchIndexResponse> searchIndex({
  required String queryString,
  String? indexName,
  int? maxResults,
  String? nextToken,
  String? queryVersion,
}) async {
  _s.validateNumRange(
    'maxResults',
    maxResults,
    1,
    1152921504606846976,
  );
  final $payload = <String, dynamic>{
    'queryString': queryString,
    if (indexName != null) 'indexName': indexName,
    if (maxResults != null) 'maxResults': maxResults,
    if (nextToken != null) 'nextToken': nextToken,
    if (queryVersion != null) 'queryVersion': queryVersion,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/indices/search',
    exceptionFnMap: _exceptionFns,
  );
  return SearchIndexResponse.fromJson(response);
}