Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Add minimum_should_match clause to or/nor filters to really filter by should clause#18

Open
cewald wants to merge 3 commits intomasterfrom
bugfix/minimum-should-match-on-or-filters
Open

Add minimum_should_match clause to or/nor filters to really filter by should clause#18
cewald wants to merge 3 commits intomasterfrom
bugfix/minimum-should-match-on-or-filters

Conversation

@cewald
Copy link
Copy Markdown

@cewald cewald commented Oct 13, 2020

If you use an or/nor filter it would be applied without a specific minimum_should_match value. This could lead into wrong results as it is not adding a reducing filter, just a or/nor that doesn't affect the results.

Example:

Consider the following final query:

{
  "query": {
    "bool": {
      "filter": {
        "bool": {
          "must": [
            {
              "terms": {
                "color": [ "blue" ]
              }
            }
          ],
          "should": [
            {
              "terms": {
                "size": [ 11 ]
              }
            },
            {
              "terms": {
                "is_in_sale": [ 1 ]
              }
            }
          ]
        }
      }
    }
  }
}

We wan't to load products that have the color "blue" and products that are "in sale" or have size "1"
– BUT without minimum_should_match we just ask for a definitiv color and the should filter must not be fulfilled as minimum_should_match is 0 by default.

@Fifciu Fifciu requested a review from gibkigonzo October 28, 2020 10:15
@cewald
Copy link
Copy Markdown
Author

cewald commented Nov 30, 2020

@Fifciu @gibkigonzo I've updated to the latest master branch – are any updated/changes necessary?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants