How to know which field within a document has the highest score?

Viewed 25

I am trying to find which field withing a document has the highest score

The closet I could get is this query. The document takes the score of the best matching field but I want to also know which field exactly was it 'field1' or 'field2'.

GET /_search
{
  "query": {
    "multi_match" : {
      "query":      "something",
      "type":       "best_fields",
      "fields":     [ "field1", "field2" ],
    }
  }
}

Basically I am trying to do an auto complete feature that could search in multiple fields inside the documents, so I am trying to know which field is best to show it to the user. The other alternative I could think of was to initially store each field in a separate document.

0 Answers
Related