Disjunctive Facets on Different Attributes

Hello,

I’m currently struggling with using the disjunctiveFacets feature in Javascript. I would like to refine my search results by a value, if this value is contained in either attribute 1 or attribute 2. Specifically, the disjunctiveFacetsRefinement would look like:

places.address_locality:value OR places.address_region:value

The way I try to achieve that is:

this.search.helper.addDisjunctiveFacetRefinement("places.address_region", value);
this.search.helper.addDisjunctiveFacetRefinement("places.address_locality", value);

That gives me no results, even though the following code gives me results:

this.search.helper.addDisjunctiveFacetRefinement("places.address_region", value);
this.search.helper.addDisjunctiveFacetRefinement("places.address_region", value);

Any assistance would be appreciated.

Cheers,
Jack

Hi @jack_walsh1
It’s kindda hard to tell what’s not working from the simple code you have.
I would start by checking you have declared both places.address_region and places.address_locality as facets in your Algolia Dashboard.
Also please send us a complete example where we can reproduce this issue. You can start off this boilerplate:

Hi Youcef,

Yep, both are facets in my dashboard. The code here will probably best illustrate what I am looking for and what is going on:

I see what’s going on, this is a confusion of what disjunctiveFacets are. The idea is that they are internally disjunctive, but still the complete query is joined conjunctively. The helper has no concept of joining disjunctively over multiple attributes.

What you’re looking for can be done with the filters parameter in the configure widget:

If you want to get more dynamic, I’d advise you to use helper.setQueryParameter('filters', 'places.address_locality:VIC OR places.address_region:VIC') in the refine function.

Thank you very much. That is exactly what I am looking for.