If the same value appears in multiple filter attributes and this filter value is being used as a rule trigger condition to add filters dynamically, only one of the filtering rules -- whichever has the lower ruleID -- will be triggered.
For example, my e-commerce sneaker site uses rules to apply dynamic filters to filter by brand
or model
whenever the user searches for a name that matches a brand or a model value. I have set up the following rules:
- CONDITION: Query contains
{facet:brand}
--> CONSEQUENCE: Filter Facetbrand
- CONDITION: Query contains
{facet:model}
--> CONSEQUENCE: Filter Facetmodel
If my site sells sneakers by a brand called "Jumpers" (brand: "Jumpers"
) and also sells sneakers from a different brand with the model Jumpers (model: "Jumpers"
), this will initiate the precedence logic tie-breaking of the two conflicting rules. Because everything other than the facet filter is a tie in terms of the precedence logic, themodel
rule is applied simply because of the fact that the rule was created first and has a lower ruleID. The "Jumpers" brand sneakers will not appear in the results.
***
Although you cannot apply both facet filters simultaneously in this scenario, there are two potential workarounds, both of which would involve creating a new rule specifically for the query "Jumpers" that is generating the conflict:
1. Create a rule with the condition that the query is "Jumpers". For the consequence, add the following query parameter:
{
"optionalFilters": [
"model:jumpers",
"brand:jumpers"
]
}
Although optionalFilters will also return results that don't match either of the filters, the parameter above will boost the Jumpers model records to the top, followed by all Jumpers brand records. Results that don't match the filters will appear in the results after both. You won't see the facets selected with this option.
2. Create a rule with the condition that the query is "jumpers". There will be two sets of consequences. The first is to pin any records for "Jumpers" models to the top of the results. For the second, add the query parameter below:
{
"facetFilters": [
"brand:jumpers"
]
}
This second option is far less scalable, as you would need to manually re-pin the "Jumpers" model records anytime these records are updated or new "Jumpers" model records are added.