The Recommendations and Pathways V2 APIs support complex boolean queries using Advanced Filters.
Similar to the efq filter for Search and Category, the complex boolean filters can be applied to Recommendations result sets to include/exclude the products using the Product Attributes in the customer feed that is valid and fits the parameter values.
Recommendations and Pathways APIs also support filtering on SKU attributes. Refer to the table below to learn about range filtering support for Pathways and Recommendations widgets.
Range filtering | Pathways widgets | Recommendations widgets |
---|---|---|
Range filtering on product-level attributes | Supported | Supported |
Range filtering on variant-level attributes | Supported | Not supported |
Read more about SKU attributes in the SKU Select API page.
Filter syntax
The filtering syntax follows these rules:
- Use the format filter=<attribute>:<value> for single-value filters.
filter=availability_flag:3
- To filter by multiple values, use parentheses ( ) and a suitable operator (OR and AND). Parentheses are required when using an operator to group multiple values for a single attribute.
Correct:filter=availability_flag:(3 OR 4)
Incorrect:filter=availability_flag:3 OR 4
- For string attributes, enclose each value in double quotes.
filter=color:("red" OR "blue")
- Use square brackets [ ] only for range queries, with the format [min TO max]. Don't use square brackets for non-range queries.
filter=price:[10 TO 100]
Filter operators
- OR: Includes items that belong to a specified set.
- AND: Include items that belong to all specified sets.
- NOT: Excludes items that belong to the specified sets.
Examples
Returns all cotton products and all linen products
&filter=fabric:("cotton" OR "linen")
Returns all products that are both cotton and linen
&filter=fabric:("cotton" AND "linen")
Returns all cotton items that aren't linen
&filter=fabric:"cotton"
&filter=-fabric:"linen"
Learn more about the
filter
parameter and its usage in the Recommendations and Pathways Parameters Reference.