0

I have two fields field_1 and field_2. I have a to find exact match for my query in either field_1 or field_2. multi_match is not giving me exact matches. And constant_score does not support multi_match.

The elasticsearch version I'm using:

Version: 6.3.0, Build: default/rpm/424e937/2018-06-11T23:38:03.357887Z, JVM: 1.8.0_171

1 Answer 1

1

After a lot of reading the docs and trying different queries this worked for me:

query = {
   "query" : {
      "constant_score" : { 
         "filter" : {
            "bool" : {
              "should" : [
                 { "term" : {"field_1" : "<search query>"}},
                 { "term" : {"field_2" : "<search query>"}}
              ]
           }
         }
      }
   }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.