# How to return highlight results in position order?

**URL:** <https://discuss.elastic.co/t/how-to-return-highlight-results-in-position-order/29820>\
**Category:** Elasticsearch\
**Created:** [September 23, 2015, 1:27am UTC](https://discuss.elastic.co/t/how-to-return-highlight-results-in-position-order/29820 "2015-09-23T01:27:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [September 23, 2015, 1:27am UTC](https://discuss.elastic.co/t/how-to-return-highlight-results-in-position-order/29820/1 "2015-09-23T01:27:14Z")

</div>

I am using highlight feature in our product with following like query:  
"highlight": {  
"fields": {  
"content": {  
"fragment\_size": 100,  
"number\_of\_fragments": 3  
}  
}  
}  
seems the default order of highlight results is based on importance, and I know I can change the order to be sorted by score by adding "order":"score" to my query.

But I would prefer the results is in the order that they appear in a paragraph instead of importance/score, I could not find any other documented options to change the return order.

Is there any way to accomplish it?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 23, 2015, 1:49am UTC](https://discuss.elastic.co/t/how-to-return-highlight-results-in-position-order/29820/2 "2015-09-23T01:49:28Z")

</div>

You can sort by "source" iirc. The experimental highlighter supports a  
"top\_scoring" option you could experiment with if you want to try it.

Nik

---

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [September 23, 2015, 2:00am UTC](https://discuss.elastic.co/t/how-to-return-highlight-results-in-position-order/29820/3 "2015-09-23T02:00:47Z")

</div>

thanks your info!  
Just curious, in that documentation I can find all these options?

---

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [September 23, 2015, 2:38am UTC](https://discuss.elastic.co/t/how-to-return-highlight-results-in-position-order/29820/4 "2015-09-23T02:38:53Z")

</div>

I just tried the "source" order, do you mean adding "order":"source" as follows?

"highlight":{  
"order": "source",  
"pre\_tags":["**"],"post\_tags":["**"],  
"fields":{  
"Description":{  
"fragment\_size":100,"number\_of\_fragments":3  
}  
}  
}

It does not work...

---

<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 5, 2017, 11:48pm UTC](https://discuss.elastic.co/t/how-to-return-highlight-results-in-position-order/29820/5 "2017-07-05T23:48:39Z")

</div>


