Disjunctive facet filters with react-instantsearch

Hey :wave:

We have a bunch of different facet filters of which we want specific ones to be disjunctive, since they only apply to a subset of our records. How can this be done with react-instantsearch?

I’ve tried setting a facetFilters prop on a <Configure /> component like so:

<Configure facetFilters={'[["docType:retspraksis", "retsforskriftsstatus:gældende"]]'} />

which works, except it can’t be disabled. Should I create some custom state handling to generate and enable/disable this filter, or is there a better way to do this?

Hey @kris, the filters prop is a simple string, no need for the brackets etc.

<Configure filters={'docType:retspraksis retsforskriftsstatus:gældende'} />

AND is implied between two filters

Sorry, it’s actually the facetFilters prop. Edited OP. Anyway, the point is we want to use OR :slight_smile:

In that case it would be:

<Configure facetFilters={[["docType:retspraksis", "retsforskriftsstatus:gældende"]]} />

Note passing it as a real array.

Another option is to use a virtual refinement list with “or” as method (but that won’t work here since there’s two different filters).

You can also use OR in filters:

<Configure filters={'docType:retspraksis OR retsforskriftsstatus:gældende'} />

Is that what you expected @kris?

Yes, somewhat. So the recommendation here, where enabling a specific facet filter should always be disjunctive like the above, is to handle it manually and send it to the <Configure /> component?

Yes, because the default operation to apply between different widgets is AND, if you wanted that behaviour you could use multiple virtual Menus.

1 Like