How to perform OR operation between attributes in React Instantsearch #6531
-
I have a use case where between two refinement lists (that is, I have two refinement lists for two different attributes) I need the search results to be OR'ed. I am using hooks to create my own UI. My user will select a value from the first refinement list and another value from the second refinement list. The search results should contain hits that either match first refinement list value OR second refinement list value (or both). I understand that in the api, we would use the filters parameter to pass the filter as foo:value1 OR bar:value2, but I am wondering if there's a Reactjs way to do it - without explicitly setting the filter parameter. Is |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
In React InstantSearch all widgets are indeed implicitly "and"ed. You have two options:
Then you can use the
Then you use the InstantSearch, or even the underlying helper does not have a way to do disjunctions across different attributes. Often a solution can be found where you for example merge both into one list, or other UIs. People in general expect filters to be joined conjunctively, but your UI may work differently. |
Beta Was this translation helpful? Give feedback.
In React InstantSearch all widgets are indeed implicitly "and"ed. You have two options:
Then you can use the
facetFilters
search parameter, formatted like[["foo:value1"],["bar:value2"]]
Then you use the
filters
parameter, formatted likefoo:value1 OR bar:value2
InstantSearch, or even the underlying helper does not have a way to do disjunctions across different attributes. Often a solution can be found where you for example merge both into one list, or other UIs. People in general expect filters to be joined conjunctively, but your UI may work differently.