meilisearch-js-plugins icon indicating copy to clipboard operation
meilisearch-js-plugins copied to clipboard

"or" operator doesn't seem to work within a refinement list (disjunctive facet search).

Open alcanari opened this issue 2 years ago • 12 comments

Hi 👋

Description

"or" operator don't work within a refinement list.

Current behavior

When I click on a refinement list, only the options that have a document in common with the option selected are shown - even if the refinement list is set with the "or" operator.

So - when I have a refinement list with exclusive options (ie. none is shared by a document - in a belong_to/has_one association), I can only display a single option within the refinement list.

But - with the "or" operator, I'd like to see other options as well that I can select, so I can select two different options from the refinement list and see the documents that have either one or the other.

Screenshots or Logs

      searchBrands.addWidget(
        panelForIndustries({
          container: "#categories",
          attribute: "industry.name",
          showMore: true,
          autoHideContainer: true,
          keepZeroFacets: true,
          operator: "or"
        })
      );

Behaviour - I have industries to search on brands. Each brand can only have one industry.

Before selecting anything:

Screenshot 2022-07-04 at 23 41 53

Here's what I'd like as a result (using Algolia, which set the default operator as "or" - so I can select and view results from two different industries - as I would expect using the "or" attribute)

Screenshot 2022-07-04 at 23 41 59

Here's the actual result by Meilisearch (the default operator being "and" - and the setting in the RefinementList doesn't seem to work)

Screenshot 2022-07-04 at 23 42 05

Environment (please complete the following information):

  • Meilisearch version: MeiliSearch 0.27.1
  • instant-meilisearch version: https://cdn.jsdelivr.net/npm/@meilisearch/instant-meilisearch/dist/instant-meilisearch.umd.min.js
  • instantsearch.js version: InstantSearch.js 4.43.0

alcanari avatar Jul 04 '22 23:07 alcanari

Hey @alcanari Unfortunately, the way it works today is that if you are doing and you have the following results:

Screenshot 2022-07-06 at 12 26 32 Screenshot 2022-07-06 at 12 26 37

and if you're using or you have the following:

Screenshot 2022-07-06 at 12 27 24 Screenshot 2022-07-06 at 12 27 26

I agree with you that this is counterintuitive! It is planned to update this behavior to what we call disjunctive facet search. When the next release of meilisearch (the engine) is out, I will be working on instant-meilisearch and on this issue as well. It should come in the following weeks. I will keep you updated once the issue is created on how disjunctive facet search works and if it seems to be what you are looking for.

meanwhile, can I suggest using keepZeroFacet option which at least will still showcase your other facets!

bidoubiwa avatar Jul 06 '22 10:07 bidoubiwa

Hey,

Thank you @bidoubiwa ! :)

I'm not sure I follow. In your examples, you have 3 games that are both Multiplayer and Single Player? If you'd only have games that would be Multiplayer or Single Player (none can be both) - would other facets show up when you're using or?

Just to make sure I understand, because I'm already using the keepZeroFacet option :)

alcanari avatar Jul 06 '22 15:07 alcanari

When you say "this is counterintuitive" -> you mean, the fact that you go from 3 to 7 for Single Player games in the using or option?

Thank you!

alcanari avatar Jul 06 '22 15:07 alcanari

When you say "this is counterintuitive" -> you mean, the fact that you go from 3 to 7 for Single Player games in the using or option?

Yes ! My bad I wasn't very clear

bidoubiwa avatar Jul 06 '22 15:07 bidoubiwa

Thank you!

Yes agreed - I understand it's related to the disjunctive facet search - got it. Just to be 100% clear - the or option on the refinement list right now changes the results of the search, but not the available options to select for now? :)

Also, did you saw my previous message? We're already using keepZeroFacets but it doesn't seem to work, which makes it hard to use in a setup where there are exclusive refinement lists options.

Hey,

Thank you @bidoubiwa ! :)

I'm not sure I follow. In your examples, you have 3 games that are both Multiplayer and Single Player? If you'd only have games that would be Multiplayer or Single Player (none can be both) - would other facets show up when you're using or?

Just to make sure I understand, because I'm already using the keepZeroFacet option :)

alcanari avatar Jul 06 '22 19:07 alcanari

Is there any idea of when this issue will be resolved? Thanks!

johnwbaxter avatar Jul 20 '22 08:07 johnwbaxter

Hello @johnwbaxter I cannot guarantee any time for the moment unfortunately :/ I will try to create the issue explaining in details how it should be implemented asap so that contributors may implement it if they want it to be released sooner

bidoubiwa avatar Jul 20 '22 09:07 bidoubiwa

I add a flag on this (we add keepZeroFacets on configuration for the moment but i'm really interesting on that behaviour

LiquidITGuy avatar Aug 30 '22 08:08 LiquidITGuy

Would be great to keep moving forward on this where possible, this is a critical feature for us

jeremylynch avatar Sep 13 '22 03:09 jeremylynch

This is a pain point for us too.

We have "or" based filter

This is the refinement list without any filters

image

When we select 1 this is what we would see (notice other options becoming 0) image

But in fact, the document count available is not 0 but 6 since this is an "or" based filter. When we select document as well, our total search hits become 10 (6+4):

image

This is what we expect to see: (filter count available, not filter count in current hits)

image

ar-siddiqui avatar Sep 13 '22 17:09 ar-siddiqui

Does anyone know when we will get an update on this one?

jeremylynch avatar Sep 17 '22 07:09 jeremylynch

Hey @jeremylynch. It is the next task we are working on :) I'll keep you updated

bidoubiwa avatar Sep 19 '22 08:09 bidoubiwa

Hello there, I'd like to ask about this feature, is there any update with that?

kamopeter avatar Oct 18 '22 13:10 kamopeter

Working on it for the moment! We have been slowed down with hacktoberfest unfortunately

bidoubiwa avatar Oct 18 '22 13:10 bidoubiwa

Working on it for the moment! We have been slowed down with hacktoberfest unfortunately

Hi @bidoubiwa, any update on this?

Happy to test on our 20k+ product database which has lots of facets if it helps.

anthonycook avatar Nov 24 '22 09:11 anthonycook

Hey @anthonycook, I'm currently working on it :) Both multi-index search and disjunctive facet search are being added simultaneously.

You can follow along #888 Which introduces the multi-index search, and should be a gate opener to adding disjunctive very efficiently

bidoubiwa avatar Nov 24 '22 10:11 bidoubiwa

Hey @anthonycook, I'm currently working on it :) Both multi-index search and disjunctive facet search are being added simultaneously.

You can follow along #888 Which introduces the multi-index search, and should be a gate opener to adding disjunctive very efficiently

Amazing! Thanks for the update, I will follow along 😊

anthonycook avatar Nov 24 '22 10:11 anthonycook

Thank you for the update @bidoubiwa !

alcanari avatar Nov 24 '22 11:11 alcanari

Sorry for my question, and maybe it's a stupid question, but when will this feature be available, would be happy to use it in existing project. Thanks!

kamopeter avatar Dec 07 '22 09:12 kamopeter

Hey @kamopeter The beta should be released this week on npm

bidoubiwa avatar Dec 07 '22 12:12 bidoubiwa

Thanks! :)

kamopeter avatar Dec 07 '22 12:12 kamopeter

The disjunctive search beta is released! Can you try it out? It is published on npm here

bidoubiwa avatar Dec 15 '22 16:12 bidoubiwa

It is released on the latest dist tag in npm and should be acting as expected with v0.11.0!

bidoubiwa avatar Feb 15 '23 12:02 bidoubiwa