# "highlight" in query cause long delay

**URL:** <https://discuss.elastic.co/t/highlight-in-query-cause-long-delay/96165>\
**Category:** Elasticsearch\
**Created:** [August 8, 2017, 12:50am UTC](https://discuss.elastic.co/t/highlight-in-query-cause-long-delay/96165 "2017-08-08T00:50:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sliu](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sliu](https://discuss.elastic.co/u/sliu)\
**Post date:** [August 8, 2017, 12:50am UTC](https://discuss.elastic.co/t/highlight-in-query-cause-long-delay/96165/1 "2017-08-08T00:50:07Z")

</div>

Use ElasticSearch 5.4.1.  
I have a query on a small index (about 30k documents) that takes over one second in search time. I find that once I remove the "highlight" block, the search time is down to about 50ms!  
"highlight": {  
"pre\_tags": ["**"],  
"post\_tags": ["**"],  
"fields": {  
"my\_search\_field": {}  
}  
}

More info: 15 total results. Query "size" is 10. I reduced "size" to 4, 6, etc, the search time do come down proportionally. "my\_search\_field" is not huge, and even if it is the default "fragment\_size" should prevent Elastic from going through all of it anyway.

Any idea why it takes so long? Thanks.

---

<div class="post-metadata">

**Author:** ![sliu](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@sliu](https://discuss.elastic.co/u/sliu)\
**Post date:** [August 8, 2017, 4:55pm UTC](https://discuss.elastic.co/t/highlight-in-query-cause-long-delay/96165/2 "2017-08-08T16:55:01Z")

</div>

Answer it myself. Changed to "postings highlighter" after reading document [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#postings-highlighter](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#postings-highlighter). The performance improved a lot (~250ms from over 1 second). Still a lot more than without highlighter (~50ms).

---

<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 5, 2017, 4:55pm UTC](https://discuss.elastic.co/t/highlight-in-query-cause-long-delay/96165/3 "2017-09-05T16:55:02Z")

</div>

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