# Highlight if all word matches

**URL:** <https://discuss.elastic.co/t/highlight-if-all-word-matches/98699>\
**Category:** Elasticsearch\
**Created:** [August 29, 2017, 1:36pm UTC](https://discuss.elastic.co/t/highlight-if-all-word-matches/98699 "2017-08-29T13:36:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HritikJain](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@HritikJain](https://discuss.elastic.co/u/HritikJain)\
**Post date:** [August 29, 2017, 1:36pm UTC](https://discuss.elastic.co/t/highlight-if-all-word-matches/98699/1 "2017-08-29T13:36:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 26, 2017, 1:36pm UTC](https://discuss.elastic.co/t/highlight-if-all-word-matches/98699/2 "2017-09-26T13:36:35Z")

</div>

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