# Searching on list in a document using highlight

**URL:** <https://discuss.elastic.co/t/searching-on-list-in-a-document-using-highlight/139899>\
**Category:** Elasticsearch\
**Created:** [July 13, 2018, 8:15am UTC](https://discuss.elastic.co/t/searching-on-list-in-a-document-using-highlight/139899 "2018-07-13T08:15:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_Wahi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhishek_wahi/32/66559_2.png) [@Abhishek\_Wahi](https://discuss.elastic.co/u/Abhishek_Wahi)\
**Post date:** [July 13, 2018, 8:15am UTC](https://discuss.elastic.co/t/searching-on-list-in-a-document-using-highlight/139899/1 "2018-07-13T08:15:58Z")

</div>

Hi all,

I am applying the prefix query on list field and using highlight query to see the matched result but it is giving first five matches. But according to requirement i want last entries in best match as my use case is to suggest search from your recent searched strings. Please suggest.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 13, 2018, 9:26am UTC](https://discuss.elastic.co/t/searching-on-list-in-a-document-using-highlight/139899/2 "2018-07-13T09:26:15Z")

</div>

> [@Abhishek\_Wahi](#):
>
> but it is giving first five matches

Try change the `number_of_fragments` [setting](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/search-request-highlighting.html#highlighting-settings)

---

<div class="post-metadata">

**Author:** ![Abhishek\_Wahi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhishek_wahi/32/66559_2.png) [@Abhishek\_Wahi](https://discuss.elastic.co/u/Abhishek_Wahi)\
**Post date:** [July 13, 2018, 11:35am UTC](https://discuss.elastic.co/t/searching-on-list-in-a-document-using-highlight/139899/3 "2018-07-13T11:35:01Z")

</div>

But list count cannot be assumed, it is increasing day by day. Also, it is not good in performance also.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 13, 2018, 12:28pm UTC](https://discuss.elastic.co/t/searching-on-list-in-a-document-using-highlight/139899/4 "2018-07-13T12:28:35Z")

</div>

> [@Abhishek\_Wahi](#):
>
> it is increasing day by day.

Unbounded growth of a document is not a good strategy.  
Indices are designed to scale but not individual docs.  
I suggest you either:

1. Cap the number of recent searches you keep in a user profile doc or
2. Have one doc per search saved then use `sort` in your query requests to get the last N

---

<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:** [August 10, 2018, 12:28pm UTC](https://discuss.elastic.co/t/searching-on-list-in-a-document-using-highlight/139899/5 "2018-08-10T12:28:42Z")

</div>

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