How to only use score of best matching term

Hey

I have four terms, Term_A, Term_B, Term_C and Term_D.
I would like to do something like this:

   {
      "query": {
        "bool" : {
          "should" : [
            { "term" : { "tags_field" : "Term_A" } },
            { "term" : { "tags_field" : "Term_B" } },
            { "term" : { "tags_field" : "Term_C" } },
            { "term" : { "tags_field" : "Term_D" } }
          ],
          "minimum_should_match" : 1,
          "boost" : 1.0,
          "score_mode": max
        }
      }
    }

Where the score_mode part should say, that I only want the document to get the score of the best matching term.
I am aware of multi-field search, but that is one queryString to multiple fields.
What I wish here is multiple queryStrings, and only get score from the best matching.

Appreciate all the help I can get :slight_smile:

(We are using elastic 1.7, but if there is a simple solution I havn't thought about, it will probably work on this old version as well :crossed_fingers:)

/Jens

Hi Jens.
Check out the dis max query.

Whoah. Might be time for an upgrade :slight_smile:

Hi Mark

That is exactly what I was looking for, thanks! :slight_smile:

And yes, it has been on our backlog for years :sweat_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.