searchForFacetValues method
Future<SearchForFacetValuesResponse>
searchForFacetValues({
- required String indexName,
- required String facetName,
- SearchForFacetValuesRequest? searchForFacetValuesRequest,
- RequestOptions? requestOptions,
Searches for values of a specified facet attribute. - By default, facet values are sorted by decreasing count. You can adjust this with the sortFacetValueBy
parameter. - Searching for facet values doesn't work if you have more than 65 searchable facets and searchable attributes combined.
Required API Key ACLs:
- search
Parameters:
indexName
Name of the index on which to perform the operation.facetName
Facet attribute in which to search for values. This attribute must be included in theattributesForFaceting
index setting with thesearchable()
modifier.searchForFacetValuesRequest
requestOptions
additional request configuration.
Implementation
Future<SearchForFacetValuesResponse> searchForFacetValues({
required String indexName,
required String facetName,
SearchForFacetValuesRequest? searchForFacetValuesRequest,
RequestOptions? requestOptions,
}) async {
assert(
indexName.isNotEmpty,
'Parameter `indexName` is required when calling `searchForFacetValues`.',
);
assert(
facetName.isNotEmpty,
'Parameter `facetName` is required when calling `searchForFacetValues`.',
);
final request = ApiRequest(
method: RequestMethod.post,
path: r'/1/indexes/{indexName}/facets/{facetName}/query'
.replaceAll(
'{' r'indexName' '}', Uri.encodeComponent(indexName.toString()))
.replaceAll(
'{' r'facetName' '}', Uri.encodeComponent(facetName.toString())),
isRead: true,
body: searchForFacetValuesRequest?.toJson(),
);
final response = await _retryStrategy.execute(
request: request,
options: requestOptions,
);
return deserialize<SearchForFacetValuesResponse,
SearchForFacetValuesResponse>(
response,
'SearchForFacetValuesResponse',
growable: true,
);
}