setAttributesForFaceting method
AttributesForFaceting
The complete list of attributes that will be used for faceting.
Use this setting for 2 reasons:
- to turn an attribute into a facet.
- o make any string attribute filterable.
By default, your index comes with no categories. By designating an attribute as a facet, this enables Algolia to compute a set of possible values that can later be used to filter results or display these categories. You can also get a count of records that match those values.
Usage notes:
- This setting enables both faceting and filtering.
- Faceting allows you to use attributes inside
facets
- Filtering allows you to use attributes inside filters, facetFilters and optionalFilter
- Faceting allows you to use attributes inside
- Default: If not specified or empty, no attribute will be faceted.
- Nested Attributes: All attributes can be used for faceting, even when nested. For example, authors.mainAuthor can be used for faceting. Here the faceting will be applied only on mainAuthor.
Source: Learn more
Implementation
AlgoliaQuery setAttributesForFaceting(List<String> value) {
assert(value.isNotEmpty, 'value can not be empty');
assert(!_parameters.containsKey('attributesForFaceting'));
return _copyWithParameters(
<String, dynamic>{'attributesForFaceting': value});
}