Highlight if all word matches

Hello Guys,

I am working with Highlight functionality with ES 2.4.x

I need to have highlight field if all the words matches. If I search for "The Old Vic" and if all three words match then only highlight should come.

I have tried below query:

"fields": ["name", "show_event_value"],                                                                                  
"query": {
"multi_match": {
	"query": "The Old Vic",
	"fields": [
		"name^2",
		"show_event_value"
	],
	"operator": "and"
}                                                                                                                                      
},                                                                                                                                          
"highlight": {
"fields": {
	"name": {},
	"show_event_value": {
		"highlight_query": {
			"match": {
				"show_event_value": {
					"query": "The Old Vic",
					"operator": "and"
				}
			}
		}
	}
}

}

And the query results are:

"hits": {
"total": 3,
"max_score": 3.3875163,
"hits": [
  {
    "_index": "local_dev_product_1_v2",
    "_type": "document",
    "_id": "12169",
    "_score": 3.3875163,
    "fields": {
      "name": [
        "The Divide - The Old Vic (London)"
      ],
      "show_event_value": [
        "The Divide"
      ]
    },
    "highlight": {
      "show_event_value": [
        "<em>The</em> Divide"
      ],
      "name": [
        "<em>The</em> Divide - <em>The</em> <em>Old</em> <em>Vic</em> (London)"
      ]
    }
  },
  {
    "_index": "affinion_dev_product_1_v2",
    "_type": "document",
    "_id": "11303",
    "_score": 3.2786121,
    "fields": {
      "name": [
        "A Christmas Carol - The Old Vic (London)"
      ],
      "show_event_value": [
        "A Christmas Carol"
      ]
    },
    "highlight": {
      "name": [
        "A Christmas Carol - <em>The</em> <em>Old</em> <em>Vic</em> (London)"
      ]
    }
  },
  {
    "_index": "affinion_dev_product_1_v2",
    "_type": "document",
    "_id": "8375",
    "_score": 3.251433,
    "fields": {
      "name": [
        "DR Seuss's the Lorax - The Old Vic (London)"
      ],
      "show_event_value": [
        "DR Seuss's the Lorax"
      ]
    },
    "highlight": {
      "show_event_value": [
        "DR Seuss's <em>the</em> Lorax"
      ],
      "name": [
        "DR Seuss's <em>the</em> Lorax - <em>The</em> <em>Old</em> <em>Vic</em> (London)"
      ]
    }
  }
]

}

I want 'show_event_value' in highlight if all words "The Old Vic" match.

Please help me, how I can fix this?

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