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!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mfrosch created an issue. See original summary.

borisson_’s picture

Category: Bug report » Support request

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.

mfrosch’s picture

Thanks for your quick feedback.
But I don't think so.
For example a laptop facet for RAM.
There is

  • 4 GB
  • 8 GB
  • 16 GB

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.

StryKaizer’s picture

Category: Support request » Bug report
Priority: Normal » Critical

Moving this to critical as this is the essence of using facets.

StryKaizer’s picture

Issue tags: +beta blocker, +Needs tests

Copy 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

marthinal’s picture

Status: Active » Needs review
Issue tags: -Needs tests +DevDaysMilan
FileSize
65.95 KB
1.31 KB
664 bytes

I 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.

Status: Needs review » Needs work

The last submitted patch, 6: search-api-2734989-6.patch, failed testing.

The last submitted patch, 6: search-api-2734989-6.patch, failed testing.

The last submitted patch, 6: 2734989-6.patch, failed testing.

The last submitted patch, 6: 2734989-6.patch, failed testing.

marthinal’s picture

Status: Needs work » Needs review
borisson_’s picture

+++ b/src/Plugin/facets/query_type/SearchApiString.php
@@ -46,7 +46,7 @@ class SearchApiString extends QueryTypePluginBase {
-        'operator' => 'and',
+        'operator' => $this->facet->getQueryOperator(),

oh, heh. Good find!

Did you file an issue for search api?

borisson_’s picture

FileSize
3.85 KB
4.74 KB

Changed our own code to use lowercase or/and everywhere as discussed. If the bot agrees, I think we can commit this.

Status: Needs review » Needs work

The last submitted patch, 13: amount_of_results-2734989-13.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
FileSize
393 bytes
5.12 KB

The last submitted patch, 13: amount_of_results-2734989-13.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 15: amount_of_results-2734989-16.patch, failed testing.

The last submitted patch, 15: amount_of_results-2734989-16.patch, failed testing.

borisson_’s picture

Version: 8.x-1.0-alpha3 » 8.x-1.x-dev

Looks like this is not as easy as we figured it would be.

borisson_’s picture

Status: Needs work » Needs review
FileSize
1.45 KB
6.2 KB

Status: Needs review » Needs work

The last submitted patch, 20: amount_of_results-2734989-20.patch, failed testing.

The last submitted patch, 20: amount_of_results-2734989-20.patch, failed testing.

borisson_’s picture

Status: Needs work » Needs review
FileSize
630 bytes
6.81 KB

Tests should be green now.

Status: Needs review » Needs work

The last submitted patch, 23: amount_of_results-2734989-23.patch, failed testing.

The last submitted patch, 23: amount_of_results-2734989-23.patch, failed testing.

borisson_’s picture

FileSize
1.03 KB
6.81 KB

Conversions from yesterday's latest patch.

borisson_’s picture

Status: Needs work » Needs review

  • borisson_ committed 1f578b1 on 8.x-1.x
    Issue #2734989 by borisson_, marthinal, Nick_vh: OR facet doesn't work
    

borisson_ credited Nick_vh.

borisson_ credited Nick_vh.

borisson_’s picture

Title: amount of results missing on active facet » OR facet doesn't work
marthinal’s picture

Status: Needs review » Reviewed & tested by the community

Great! looks good! Thanks!

borisson_’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ressa’s picture

Just 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.