# Highlighted Results

**URL:** <https://discuss.elastic.co/t/highlighted-results/21958>\
**Category:** Elasticsearch\
**Created:** [February 3, 2015, 3:32pm UTC](https://discuss.elastic.co/t/highlighted-results/21958 "2015-02-03T15:32:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guang\_Chen](https://avatars.discourse-cdn.com/v4/letter/g/d9b06d/32.png) [@Guang\_Chen](https://discuss.elastic.co/u/Guang_Chen)\
**Post date:** [February 3, 2015, 3:32pm UTC](https://discuss.elastic.co/t/highlighted-results/21958/1 "2015-02-03T15:32:53Z")

</div>

Hi guys,

I'm having some issues with highlight queries. Not all the criteria are  
highlighted.

...  
"highlight": {  
"fields": {  
"body": {  
"type": "plain"  
}  
},  
"fragment\_size": 500,  
"highlight\_query": {  
"span\_near": {  
"clauses": [  
{  
"span\_term": {  
"body": "apple"  
}  
},  
{  
"span\_term": {  
"body": "iphone"  
}  
}  
],  
"in\_order": false,  
"slop": 5  
}  
},  
"number\_of\_fragments": 5,  
"require\_field\_match": true  
},  
...

When i ran the above query, it returned the correct documents; all the  
results contain apple and iphone within 5 words apart. Some of the  
highlight looks correct, but i saw a few highlights where snippets that it  
return are like ....  
"iphone (some additional text here...) " where it doesn't  
container the word "apple". When i check the doc itself, i see that the  
word "apple" appears right before "iphone". So why is elasticsearch not  
centering the highlighted snippets around the matched terms?

Is there anything i can do to center the matches terms?

Thanks,  
Guang

--  
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/d0e0c34a-cdfe-42ee-9f02-088be660086c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d0e0c34a-cdfe-42ee-9f02-088be660086c%40googlegroups.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:35am UTC](https://discuss.elastic.co/t/highlighted-results/21958/2 "2017-07-06T00:35:11Z")

</div>


