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 such asin,gt,gte,lt,lte,exists,not_in,not_eq,not_exists.valueis the value theoperatorcompares against in theattribute.
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 for Filter Language
When crafting filter expressions:- Test complex expressions in a controlled environment before deployment.
- Ensure consistent case usage for string attributes to prevent mismatches.
Advanced Concepts
- Nested Expressions: Combine multiple levels of conditions.
Troubleshooting Filter Expressions
If your filter expression isn’t returning the expected results:- Check for correct operator usage.
- Confirm that attribute names and values match exactly with the data.