# Sorting fragments returned by hit highlighting

**URL:** <https://discuss.elastic.co/t/sorting-fragments-returned-by-hit-highlighting/278707>\
**Category:** Elasticsearch\
**Created:** [July 14, 2021, 7:16pm UTC](https://discuss.elastic.co/t/sorting-fragments-returned-by-hit-highlighting/278707 "2021-07-14T19:16:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timforr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timforr/32/91640_2.png) [@timforr](https://discuss.elastic.co/u/timforr)\
**Post date:** [July 14, 2021, 7:16pm UTC](https://discuss.elastic.co/t/sorting-fragments-returned-by-hit-highlighting/278707/1 "2021-07-14T19:16:35Z")

</div>

I have documents with multiple content fields which I am getting highlighted fragments from.

The fragments from within the same field are sorted according to score, but the order the fields are returned in is random.

I need a way of sorting fragments globally. Just being able to sort fragments within a field is not useful if I don't know which field contains the best fragment. In practice, this has lead to very poor high highlights being displayed to users... Is there a feature I'm missing or a suggested fix besides consolidating all the fields into one field?

---

<div class="post-metadata">

**Author:** ![timforr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timforr/32/91640_2.png) [@timforr](https://discuss.elastic.co/u/timforr)\
**Post date:** [August 2, 2021, 4:04pm UTC](https://discuss.elastic.co/t/sorting-fragments-returned-by-hit-highlighting/278707/2 "2021-08-02T16:04:45Z")

</div>

I ended up just using copy\_to to consolidate all the relevant fields into one field which can be searched and highlighted on. It works, but the downside is data duplication.

---

<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 30, 2021, 4:05pm UTC](https://discuss.elastic.co/t/sorting-fragments-returned-by-hit-highlighting/278707/3 "2021-08-30T16:05:36Z")

</div>

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