Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I have a facet with "list of links" widget, checkmark on "Show the amount of results" and operator "OR".
If no facet is active I get a view like that:
- Test A (5)
- Test B (3)
- Test C (1)
If I now activate Test B the next view will be like:
- Test A
- (-) Test B (3)
- Test C
So the count of the not active one is missing. But if I click on them, the results will get added correctly.
The missing results also affect the option "Count limit". If I activate "Count limit" with min: 1. The facet A and C get removed.
Do you got an idea? Thanks!
Comment | File | Size | Author |
---|---|---|---|
#26 | amount_of_results-2734989-26.patch | 6.81 KB | borisson_ |
Comments
Comment #2
borisson_I think this is because you are using an "OR" facet, that excludes other items from the query, if you use an "AND" query, the results should show up as expected.
Comment #3
mfrosch CreditAttribution: mfrosch commentedThanks for your quick feedback.
But I don't think so.
For example a laptop facet for RAM.
There is
I want to filter for all 8 GB and 16 GB Laptops. So I need the OR operator. And as I said, it's working correctly, just the amount of results is missing.
Comment #4
StryKaizerMoving this to critical as this is the essence of using facets.
Comment #5
StryKaizerCopy past from another (duplicate) issue:
When using an OR with 'Show the amount of results' enabled, certain facets show up having a count of (0)
Those facet-items actually have another count then 0 (as facet-items with actual 0 results should'nt and are not visible).
I tested this with search_api_db, we need to test if the same issue occurs using search_api_solr
Comment #6
marthinal CreditAttribution: marthinal commentedI can reproduce the bug using search_api_solr so let's try to fix the problem.
We are hard-coding the operator. This patch fixes the problem.
It is not clear to me if we want to use lowercase or uppercase for the operator, so adding a patch for SearchAPI because actually we are using uppercase by default.
The patch should fail because we need to apply the searchAPI patch or use lowercase.
Comment #11
marthinal CreditAttribution: marthinal commentedComment #12
borisson_oh, heh. Good find!
Did you file an issue for search api?
Comment #13
borisson_Changed our own code to use lowercase or/and everywhere as discussed. If the bot agrees, I think we can commit this.
Comment #15
borisson_Comment #19
borisson_Looks like this is not as easy as we figured it would be.
Comment #20
borisson_Comment #23
borisson_Tests should be green now.
Comment #26
borisson_Conversions from yesterday's latest patch.
Comment #27
borisson_Comment #31
borisson_Comment #32
marthinal CreditAttribution: marthinal commentedGreat! looks good! Thanks!
Comment #33
borisson_Comment #35
ressa CreditAttribution: ressa at Ardea commentedJust to help others who might end up here searching for help with a faulty OR Operator: If the facet only uses the first facet, even though the Operator has been set to "OR", check if your Search API index Type is set to Fulltext, when it should be Integer. I had set Type to Fulltext and facets were populated and almost working, except that only the first facet selected had an effect, but not the second or third facet. Changing index Type to Integer fixed it.