search method

Future<SearchResponses> search({
  1. required SearchMethodParams searchMethodParams,
  2. RequestOptions? requestOptions,
})

Sends multiple search requests to one or more indices. This can be useful in these cases: - Different indices for different purposes, such as, one index for products, another one for marketing content. - Multiple searches to the same index—for example, with different filters.

Required API Key ACLs:

  • search

Parameters:

  • searchMethodParams Muli-search request body. Results are returned in the same order as the requests.
  • requestOptions additional request configuration.

Implementation

Future<SearchResponses> search({
  required SearchMethodParams searchMethodParams,
  RequestOptions? requestOptions,
}) async {
  final request = ApiRequest(
    method: RequestMethod.post,
    path: r'/1/indexes/*/queries',
    isRead: true,
    body: searchMethodParams.toJson(),
  );
  final response = await _retryStrategy.execute(
    request: request,
    options: requestOptions,
  );
  return deserialize<SearchResponses, SearchResponses>(
    response,
    'SearchResponses',
    growable: true,
  );
}