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
/
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | interdiff_6_10.txt | 5.98 KB | ericgsmith |
| #10 | facet_missing_operator-3344081-10.patch | 8.01 KB | ericgsmith |
Issue fork facets-3344081
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
herved commentedComment #3
stefan.kornI can confirm the issue and confirm that the patch solves the issue.
Thanks @herved
Comment #4
ericgsmith commented+1 for RTBC
Comment #5
ericgsmith commentedAdding a test for this
Comment #6
ericgsmith commentedFixed coding standards error in test.
The 2 failed tests are currently failing in the 2.0.x branch (https://www.drupal.org/pift-ci-job/2658100).
Comment #6 is still just test only addition from #2 which had no failures - I will try remember to come back and retest it assuming the tests in the main branch will get fixed some time soon.
Comment #7
ericgsmith commentedComment #8
herved commentedI wonder, does the exclude facet option work with this condition?
I think it won't but I have not tested yet.
Comment #9
ericgsmith commentedYou are correct, this does break the exclude logic.
I think having the separate condition group for the missing condition is correct, and the missing condition group operator could be determined based on the exclude value.
Comment #10
ericgsmith commentedHow does that look?
Improved the test a bit to more clearly show the expected condition groups.
Comment #11
ericgsmith commentedComment #13
ericgsmith commentedMoved patch to MR - CI shows test job passing + expected failure of the test only change
Comment #14
ericgsmith commentedRebased MR - noting tests currently failing due to #3579256: Failing DefaultFacetManagerTest