# ElasticSearch Highlighting not doing what I would expect

**URL:** <https://discuss.elastic.co/t/elasticsearch-highlighting-not-doing-what-i-would-expect/364831>\
**Category:** Elasticsearch\
**Created:** [August 13, 2024, 12:26pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-not-doing-what-i-would-expect/364831 "2024-08-13T12:26:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akesh\_Jadhav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akesh_jadhav/32/121839_2.png) [@Akesh\_Jadhav](https://discuss.elastic.co/u/Akesh_Jadhav)\
**Post date:** [August 13, 2024, 12:26pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-not-doing-what-i-would-expect/364831/1 "2024-08-13T12:26:38Z")

</div>

Hi,  
I am performing one regex query on the keyword field  
POST 1101741821\_mails/\_search  
{  
"query": {  
"regexp": {  
"body.not\_analyzed": "._hello my._"  
}  
},  
"highlight": {  
"fields": {  
"body.not\_analyzed": {  
"pre\_tags": ["_"],  
"post\_tags": ["_"]  
}  
}  
}  
}  
and my response is coming up like  
"highlight" : {  
"body.not\_analyzed" : [  
"""_Hello my name is Joe Bloggs did you know that?_

 

"""  
]  
}  
}

So here my whole content is getting highlighted instead of only hello my what should I change in the highlight configuration I can't change the regex query

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [August 13, 2024, 5:02pm UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-not-doing-what-i-would-expect/364831/2 "2024-08-13T17:02:14Z")

</div>

Hi @Akesh_Jadhav

I recommend read [Control highlighted fragments](https://www.elastic.co/guide/en/elasticsearch/reference/current/highlighting.html#control-highlighted-frags).

---

<div class="post-metadata">

**Author:** ![Akesh\_Jadhav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akesh_jadhav/32/121839_2.png) [@Akesh\_Jadhav](https://discuss.elastic.co/u/Akesh_Jadhav)\
**Post date:** [August 14, 2024, 2:51am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-not-doing-what-i-would-expect/364831/3 "2024-08-14T02:51:34Z")

</div>

Hi, can you help me with this? I didn't how it solve my problem.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [August 14, 2024, 10:07am UTC](https://discuss.elastic.co/t/elasticsearch-highlighting-not-doing-what-i-would-expect/364831/4 "2024-08-14T10:07:56Z")

</div>

I believe you can configure the number\_of\_fragments and fragment\_size. To help better, you would have to provide an example of an indexed document and the mapping to know what this .not\_analized field is.
