The operator used for the missing facet item is incorrect

Created on 23 February 2023, about 2 years ago

Problem/Motivation

There seems to be an issue with the facet.missing (Show missing) feature for facets based on multi-valued fields using OR operator.

When enabling the feature on such facet, the facet count is correct, but the filtering is wrong and returns most of the time all documents.
It looks like the operator within the condition group is determined by the facet operator itself, as seen here, which is currently set to OR in such cases.

It doesn't look correct, if we have 4 documents with values:
- D1: A, B, C
- D2: B
- D3: A, C
- D4: /

We want to return 1 result: !A AND !B AND !C -> D4
Instead of currently 3 results: !A OR !B OR !C -> D2, D3, D4
In other words, I believe the operator within this condition group should always be an AND.

Steps to reproduce

On a standard profile:
- Enable search_api, search_api_db_defaults and facets
- Create a facet for field_tags (operator: OR, Show the amount of results: enabled, Show missing: enabled) and display it from blocks
- Create some tags terms and some article documents (with e.g. values as explained above)
- When filtering on "Other (1)" we get D2, D3, D4 instead of D4

Note: the result is the same with search_api_solr

Proposed resolution

I can't see any situation where an OR operator would be needed, so update SearchApiString to create a condition group for the facet.missing feature and always apply an AND.

Remaining tasks

/

User interface changes

/

API changes

/

Data model changes

/

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇧🇪Belgium herved

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024