# Operator "and" in highlighting

**URL:** <https://discuss.elastic.co/t/operator-and-in-highlighting/22707>\
**Category:** Elasticsearch\
**Created:** [March 17, 2015, 12:56pm UTC](https://discuss.elastic.co/t/operator-and-in-highlighting/22707 "2015-03-17T12:56:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vlad\_Zaitsev](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@Vlad\_Zaitsev](https://discuss.elastic.co/u/Vlad_Zaitsev)\
**Post date:** [March 17, 2015, 12:56pm UTC](https://discuss.elastic.co/t/operator-and-in-highlighting/22707/1 "2015-03-17T12:56:14Z")

</div>

I noticed some strange behavior of highlighter. It works in a different way  
to search.  
See example.

request:  
{  
"highlight": {  
"pre\_tags": [  
""  
],  
"post\_tags": [  
""  
],  
"fields": {  
"message": {}  
}  
},  
"query": {  
"constant\_score": {  
"query": {  
"bool": {  
"should": [  
{  
"multi\_match": {  
"query": "meat",  
"analyzer": "standard",  
"operator": "and",  
"fields": [  
"message"  
]  
}  
},  
{  
"multi\_match": {  
"query": "fresh cucumbers",  
"analyzer": "standard",  
"operator": "and",  
"fields": [  
"message"  
]  
}  
}  
]  
}  
}  
}  
}  
}

Response:  
{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "test",  
"\_type": "test",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"message": "meat, flacky cucumbers"  
},  
"highlight": {  
"message": [  
"meat, flacky cucumbers"  
]  
}  
}  
]  
}  
}

"meat, flacky cucumbers" would not be found by "query": "fresh cucumbers",  
"analyzer": "standard", "operator": "and"  
But it seems that highlighter ignore operator: “and” and highlight any term  
from queries.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/eee2fd27-a852-4eb3-915d-5a4196e7aafa%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/eee2fd27-a852-4eb3-915d-5a4196e7aafa%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [March 17, 2015, 4:00pm UTC](https://discuss.elastic.co/t/operator-and-in-highlighting/22707/2 "2015-03-17T16:00:29Z")

</div>

On Tue, Mar 17, 2015 at 8:56 AM, Vlad Zaitsev [vestild@gmail.com](mailto:vestild@gmail.com) wrote:

But it seems that highlighter ignore operator: “and” and highlight any term

> from queries.

Its much more than that. For the most part highlighters reduce the query  
to a list of terms blindly. Some do phrases. They don't really have that  
nuanced a view of the query itself.

Its because highlighting is totally decoupled from the actual search  
portion of the job - its more like a recheck. And Lucene isn't built to  
cleanly plug the highlighters into the queries. So they have tons of  
instanceof style hacks to get the job done. Its not super pleasant.

Nik

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAPmjWd0t%3DHwt-mMpTSbw6B9vLBwDk8%3DsZS88F3g%2BfXATgC\_SGw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPmjWd0t%3DHwt-mMpTSbw6B9vLBwDk8%3DsZS88F3g%2BfXATgC_SGw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:26am UTC](https://discuss.elastic.co/t/operator-and-in-highlighting/22707/3 "2017-07-06T00:26:10Z")

</div>


