setNumericFilter method
NumericFilters
Filter on numeric attributes.
Warning
The filters parameter provides an easier to use, SQL-like syntax. We recommend using it instead of this setting.
Numeric Comparisons
Format: ${attributeName} ${operator} ${operand}
Example: inStock > 0
.
Supported operators are <
, <=
, =
, !=
, >=
and >
, with the same semantics as in virtually all programming languages.
Numeric Range
Format: ${attributeName}:${lowerBound} TO ${upperBound}
Example: price:5.99 TO 100
${lowerBound}
and ${upperBound}
must be numeric. Both are inclusive.
Usage notes:
- No boolean operators: You cannot use boolean operators like AND and OR.
- 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.
Source: Learn more
Implementation
AlgoliaQuery setNumericFilter(String value) {
final numericFilters = List<String>.from(_parameters['numericFilters']);
assert(numericFilters.where((String item) => value == item).isEmpty,
'NumericFilters $value already exists in this query');
numericFilters.add(value);
return _copyWithParameters(
<String, dynamic>{'numericFilters': numericFilters});
}