Filter Basics
Thefilter_group API parameter refines results by selecting only the products that match the given expressions and running the query on those products. The filter_group expects a filter expression.
Expressions and Operators
Expressions are the core of the filter language.propertyis the attribute of the field you want to filter on.operatoris the logical operator to apply (see full list below).valuesis an array of values theoperatorcompares against in theproperty.
Supported operators
| Operator | Description |
|---|---|
eq | Equal to a single value |
neq | Not equal to a single value |
in | Matches any value in the array |
notIn | Does not match any value in the array |
gt | Greater than |
gte | Greater than or equal to |
lt | Less than |
lte | Less than or equal to |
between | Within a range (pass exactly two values) |
notBetween | Outside a range (pass exactly two values) |
contains | String contains the given value |
doesNotContain | String does not contain the given value |
beginsWith | String starts with the given value |
endsWith | String ends with the given value |
doesNotBeginWith | String does not start with the given value |
doesNotEndWith | String does not end with the given value |
null | Value is null or does not exist |
notNull | Value is not null (exists) |
Examples of Basic Conditions
A condition to find products of typeSweaters:
Complex Filter Expressions
You can build advanced filter groups by combining expressions usingAND and OR.
Example of Complex Expression
To include bothAccessories and products from SUPREME published after 1 January 2020:
Best practices
When crafting filter expressions:- Test complex expressions in a controlled environment before deployment.
- Ensure consistent case usage for string attributes to prevent mismatches.
- Use the
betweenoperator instead of combininggteandltefor range queries. - Nested filter groups support up to two levels of depth.
Troubleshooting
If your filter expression isn’t returning the expected results:- Verify that operator names use the exact camelCase format shown above (e.g.,
notIn, notnot_in). - Confirm that attribute names and values match exactly with the data.
- Ensure the
valuesfield is always an array, even for single-value operators likeeq. - Check that the
conditionalfield uses uppercaseANDorOR.