Facet OR: global aggregation does not take views filter into account

Created on 19 November 2018, about 6 years ago
Updated 16 January 2023, almost 2 years ago

Hello,

I am using elasticsearch connector and I have a view listing event in the future (filter in the view).

Facets on event fields are with the operator OR and display tags or values from past events. Also the amount of results is not what is expected.

Looking into the code, it comes from elasticsearch_connector/src/Plugin/search_api/backend/SearchApiElasticsearchBackend.php parseFacets() which in my case use the "_global" aggregations from elasticsearch results.

I am not familiar with Elasticsearch, I will search for that, but I don't understand why the "_global" aggregations do not take filters into account.

πŸ› Bug report
Status

Needs review

Version

7.0

Component

Elasticsearch Connector Search API

Created by

πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡¬πŸ‡§United Kingdom guy_schneerson

    The patch did not work for me as is. Looks like I have a similar issue as that of #29. The existence of the aggregations _global data courses the main if condition to be skipped and the count, as a result, is wrong. Removing that part of the condition causes that block to run every time and the counts look correct.
    I am using a locally modified patch but I assume it is not the correct solution, I just don't have enough understanding of the issue to figure it out.

  • πŸ‡«πŸ‡·France Renrhaf πŸ“ Strasbourg 🐦🦜

    I had to revert the update because of some issues with this patch with the new version. Will try again later and update my comment.

  • Patch in #42 did not work for me.
    Is there any solution for this issue?

  • Status changed to Needs review almost 2 years ago
  • Patch #44 works for me.
    But I am facing issue when there is a exposed filter search text box along with facets. When there is any keyword entered into the search text box of a ajax enabled view, the facet should also filter out accordingly.

  • Status changed to RTBC almost 2 years ago
  • πŸ‡ΊπŸ‡¦Ukraine artemboiko Lviv

    Thanx works fine, tested without ajax

  • heddn Nicaragua

    I'm not sure the issue title and description are quite accurate. But this does fix many of the issues I'm seeing w/ using a multi lingual website with multiple facets. The facets counts were "off" and generally elastic search wasn't matching what we had configured using Solr. With the patch, all those issues went away.

    This could use an updated IS.

  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jlstrecker Athens, Ohio, USA

    The latest patch (#44) partly breaks result counts for facets that use the AND operator.

    Basic steps to reproduce:

    • Set up a search page with a full-text search and one facet (list of links, AND operator).
    • Click on one of the facet links.
      • Without the patch, the counts on the facet links are updated to reflect that the result set has been narrowed.
      • With the patch, the counts on the facet links fail to update.

    Tested on a fresh Drupal 10 installation with:

    • Elasticsearch Connector 8.x-7.0-alpha4 + patch #44
    • Umami installation profile
    • Search index of Article content with fields for Title (fulltext) and Tags
    • View showing indexed Title field with exposed filter for fulltext search
    • Facet for Tags field β€” List of links, Show the amount of results, Operator=AND
  • πŸ‡ͺπŸ‡ΈSpain Carlitus

    My problem was:

    I have n facets, for example:
    Quality
    - New (100)
    - Medium (300)
    - Poor (50)

    Family
    - Item family 1 (500)
    - Item family 2 (30)
    ...

    I want users to be able to filter on each of the facets with as many facet items as they want, using an OR.

    But between the different facets it has to be an AND.

    That is, if someone selects Item family 2 and Quality new and Quality Poor it would really be:

    (Item family 2) AND (Quality New OR Quality Poor)

    This already works this way by default, but it is not reflected in the number of results, so the logic that can be applied to the facets according to the results does not work well. For example hide a facet item if the results are 0. Or hide a facet if it is empty, having all its facet items deactivated.

    Without the patch this doesn't work like that, but applying patch #44 it seems to work perfectly. Thanks to everyone who made this possible!

    I'm using:
    "drupal/search_api":"^1.34",
    "drupal/elasticsearch_connector": "7.x-dev@dev",
    "drupal/facets": "^2.0",

  • πŸ‡¦πŸ‡ΊAustralia tisteegz

    Drupal - 10.2.7
    Elastic search connector - 8.x-7.0-alpha5

    Same issue as above, OR amongst checkboxes but then AND between facets which functionally works but the numbers weren't correct. Patch #44 applied and solved the number issue however it now removes the options which will have 0 results which is not the behaviour we are after. We have it set to not remove any options even if they won't narrow down the search, we would rather make them 'inactive' instead of them disappearing.

Production build 0.71.5 2024