Is it possible to highlight only match_phrase query?


(Chintan Shah) #1

Hi,

I have a bool query like this

{
  "query": {
    "bool": {
      "must": [
        {
          "terms": {
            "type": [
              "bill",
              "press release"
            ]
          }
        },
        {
          "match_phrase": {
            "title": "health"
          }
        }
      ]
    }
  },
  "highlight": {
    "fields": {
      "policy_content": {}
    }
  },
  "sort": [
    {
      "publishdate": {
        "order": "desc"
      }
    }
  ]
}

User is searching for the word health and I only want to highlight "health" but 'bill' and 'press releases" also gets highlighted, How should I address this problem?

Thank You


(Nik Everett) #2

You can do that with highlight_query.


(system) #3