facetFilter with OR using menu widget [instantSearch]

Hello guys,
I am new to Algolia InstantSearch js plugin, first project using it.
I have the following page: http://lmt.meevo.ca/browse
When a user selects a city (from the City filter which is using instantsearch.widgets.menu), I want to show courses in the selected city + another “virtual” city (the first option). So, show all courses in Toronto for example and all virtual ones).

I tried a lot of approaches but none of those work and I thought you guys are more experimented. Can you give me a hint on how to achieve that?

BTW: I also tried with query rules but i do not know how to configure that.

Hi @filip, on your website right now I see in current filters after selecting a city:

It seems it already pre-selected some virtual, either you fixed your issue or maybe it’s still broken.

What does “virtual” means in your business case? So that I can better understand.

Can you maybe explain to me what you would want to filter on given a small data example when you click on Toronto, right now it would refine on the city attribute, on which other attribute would you like to refine when clicking on Toronto?

Let me know.

Hi,

I kind of found a sollution. I change the filter to be a refinementList then when clicking on an option, i made this:

if(this.innerText.indexOf('Virtual') < 0) {
    helper.addDisjunctiveFacetRefinement('city.description',  'Virtual')
  }

This way it always selectes virtual locations too. But I was looking for a more “invisible” solution so that whenever city.description is refined, it always includes city.description:Virtual too (along with the selected City)

So basically, “Virtual” is stored just like a city.

Hey, where do you put this code in your app?

If you want to change the filters dynamically, you could use searchFunction: https://community.algolia.com/instantsearch.js/v2/instantsearch.html#struct-InstantSearchOptions-searchFunction.

You will receive the helper so you can call that exact same line of yours and achieve the same.

Let me know how it goes.