3
{  
  "query":{  
    "constant_score":{  
      "filter":{  
        "bool":{  
          "should":{  
            "terms":{  
              "field_a":[  
                "value1", "value2"
              ]
            }
          },
          "must":{  
            "term":{  
              "field_b":"value"
            }
          }
        }
      }
    }
  }
}

This search was supposed to return the results containing value1 or value2 in field_a and value in field_b.

So similar to this MySQL query:

SELECT * FROM table WHERE field_a IN ('value1', 'value2') AND field_b = value

After the upgrade it will return all the results where field_b = value. The first part of the query is completely ignored.
Any suggestions for a fix?

Marvin Saldinger
  • 1,290
  • 1
  • 16
  • 34

1 Answers1

3

You are running into this breaking change. minimum_should_match is no longer being set to 1. To correct this, explicitly set your minimum_should_match to 1

Your new query could be fixed like this:

{  
  "query":{  
    "constant_score":{  
      "filter":{  
        "bool":{  
          "should":{  
            "terms":{  
              "field_a":[  
                "value1", "value2"
              ]
            }
          },
          "minimum_should_match": 1,
          "must":{  
            "term":{  
              "field_b":"value"
            }
          }
        }
      }
    }
  }
}
Doron Yaacoby
  • 9,412
  • 8
  • 48
  • 59
Benjamin Trent
  • 7,378
  • 3
  • 31
  • 41