setFacetFilter method

  1. @Deprecated('Use `facetFilter(String value)` instead. This method will be deprecated from version ^1.1.0')
AlgoliaQuery setFacetFilter(
  1. dynamic value
)

FacetFilters

Filter hits by facet value.

Usage notes:

  • Format: The general format for referencing a facet value is ${attributeName}:${value}. This attribute/value combination represents a filter on a given facet value.
  • Multiple filters: If you specify multiple filters, they are interpreted as a conjunction (AND). If you want to use a disjunction (OR), use a nested array.
    • ['category:Book', 'author:John Doe'] translates as category:Book AND author:'John Doe'.
    • [['category:Book', 'category:Movie'], 'author:John Doe'] translates as (category:Book OR category:Movie) AND author:'John Doe'.
  • Negation is supported by prefixing the value with a minus sign (-), sometimes called a dash. For example: ['category:Book', 'category:-Movie'] translates as category:Book AND NOT category:Movie.
  • Escape characters: On the other hand, if your facet value starts with a -, meaning it contains the -, then you can escape the character with a \ to prevent the engine from interpreting this as a negative facet filter. For example, filtering on category:\-Movie will filter on all records that have a category equal to “-Movie”.

Source: Learn more

Implementation

@Deprecated(
    'Use `facetFilter(String value)` instead. This method will be deprecated from version ^1.1.0')
AlgoliaQuery setFacetFilter(dynamic value) {
  assert(value is String || value is List<String>,
      'value must be either String | List<String> but was found `${value.runtimeType}`');
  final facetFilters = List<dynamic>.from(_parameters['facetFilters']);
  assert(facetFilters.where((dynamic item) => value == item).isEmpty,
      'FacetFilters $value already exists in this query');
  facetFilters.add(value);
  return _copyWithParameters(<String, dynamic>{'facetFilters': facetFilters});
}