# Own sort order

**URL:** <https://discuss.elastic.co/t/own-sort-order/147074>\
**Category:** Elasticsearch\
**Created:** [September 3, 2018, 12:14pm UTC](https://discuss.elastic.co/t/own-sort-order/147074 "2018-09-03T12:14:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cece123](https://avatars.discourse-cdn.com/v4/letter/c/b5a626/32.png) [@cece123](https://discuss.elastic.co/u/cece123)\
**Post date:** [September 3, 2018, 12:14pm UTC](https://discuss.elastic.co/t/own-sort-order/147074/1 "2018-09-03T12:14:01Z")

</div>

Hi!  
I need use in elasticsearch my own sort order for example:  
I have info about Food with food\_category\_id and I want sort result by food\_category\_id in order [5,8,2] (First with id = 5, second with id = 8. third with id = 2).  
It is possible to do that? Can you help me?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 4, 2018, 8:30am UTC](https://discuss.elastic.co/t/own-sort-order/147074/2 "2018-09-04T08:30:02Z")

</div>

hey,

how about just executing three queries instead then? alternatively have a look at the [function score query](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/query-dsl-function-score-query.html)

--Alex

---

<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:** [October 2, 2018, 8:30am UTC](https://discuss.elastic.co/t/own-sort-order/147074/3 "2018-10-02T08:30:09Z")

</div>

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