setFacets method

AlgoliaQuery setFacets(
  1. List<String> value
)

Facets

Facets to retrieve.

The effect of this setting: For each of the retrieved facets (eg. color; size), the response will contain a list of facet values (blue, red; small, large, …) in objects matching the current query. Each value will be returned with its associated count (number of matched objects containing that value).

The maximum number of facet values returned depends on the maxValuesPerFacet setting. The default is 100 and the max is 1000.

By default, the returned values are sorted by frequency, but this can be changed to alphabetical with sortFacetValuesBy.

Usage notes:

  • Facets must have been declared beforehand in the attributesForFaceting index setting.
  • Faceting does not filter your results. If you want to filter results, you should use filters.
  • Default/Empty list: If not specified or empty, no facets are retrieved. The special value * may be used to retrieve all facets.
  • **Approximating facet counts:(()) If the number of hits is high, facet counts may be approximate. The response field exhaustiveFacetsCount is true when the count is exact.

Source: Learn more

Implementation

AlgoliaQuery setFacets(List<String> value) {
  assert(value.isNotEmpty, 'value can not be empty');
  assert(!_parameters.containsKey('facets'));
  return _copyWithParameters(<String, dynamic>{'facets': value});
}