search method

Future<Map<String, dynamic>> search({
  1. String? query,
  2. SynonymsType? type,
  3. int page = 0,
  4. int hitsPerPage = 100,
})

Search synonyms

Search or browse all synonyms, optionally filtering them by type.

  • query: Search for specific synonyms matching this string. Use an empty string (default) to browse all synonyms.

  • type: Only search for specific types of synonyms. Multiple types can be specified using a comma-separated list. Possible values are: synonym, onewaysynonym, altcorrection1, altcorrection2, placeholder.

  • page: Number of the page to retrieve (zero-based).

  • hitsPerPage: Maximum number of synonym objects to retrieve.

Implementation

Future<Map<String, dynamic>> search({
  String? query,
  SynonymsType? type,
  int page = 0,
  int hitsPerPage = 100,
}) async {
  var data = {
    'query': query,
    'type': type,
    'page': page,
    'hitsPerPage': hitsPerPage,
  };
  data.removeWhere((key, value) => value == null);
  var response = await algolia._apiCall(
    ApiRequestType.post,
    'indexes/$encodedIndex/synonyms/search',
    data: data,
  );
  Map<String, dynamic> body = json.decode(response.body);
  if (!(response.statusCode >= 200 && response.statusCode < 500)) {
    throw AlgoliaError._(body, response.statusCode);
  }
  return body;
}