Elastic search order of the highlighted fields not matching with the ranking

Hello,

In the below document, I am trying to match multiple fields and I also want to know what fields are getting matched from the document that's why used the highlighted fields.

sample doc:

{
	"therapeutic_area": "pain management",
	"indications": [
	        "Dental conditions",
            "Dental pain",
            "Neurological conditions",
            "Pain management",
            "Acute and chronic pain",
            "Pre/Post surgical pain"
	]
}

query:

"query": {
    "multi_match": {
      "query": "dental pain",
      "type": "best_fields",
      "fields": [
        "therapeutic_area",
        "indications",
      ]
    }
  },
  "highlight": {
    "fields": [
      {
        "therapeutic_area": {}
      },
      {
        "indications": {}
      }
    ]
  }

and the highlighted result that I got is like below

"highlight": {
          "therapeutic_area": [
            "Trauma/Pain management"
          ],
          "indications": [
            "Dental conditions",
            "Dental pain",
            "Pain management",
            "Acute and chronic pain",
            "Pre/Post surgical pain"
          ]
        }

now the problem here is while I am looping over the keys from highlight field (therapeutic_area, indications) I am not able to get the rankings properly as therapeutic_area, indications are does not follow the rankings.

my question is how can I get proper rankings in the highlighted field?

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