# Ordering results by terms filter

**URL:** <https://discuss.elastic.co/t/ordering-results-by-terms-filter/36059>\
**Category:** Elasticsearch\
**Created:** [December 1, 2015, 2:44pm UTC](https://discuss.elastic.co/t/ordering-results-by-terms-filter/36059 "2015-12-01T14:44:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonsgreen](https://avatars.discourse-cdn.com/v4/letter/j/e9bcb4/32.png) [@jonsgreen](https://discuss.elastic.co/u/jonsgreen)\
**Post date:** [December 1, 2015, 2:44pm UTC](https://discuss.elastic.co/t/ordering-results-by-terms-filter/36059/1 "2015-12-01T14:44:10Z")

</div>

I am relatively new to elasticsearch. I am doing a simple filter query by terms using ids:

```
{ filter: { terms: { id: [3, 5, 8] } } }

```

However, the results do not come sorted by the order of the values. Is there a simple way to achieve this within elasticsearch?

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [December 4, 2015, 2:02am UTC](https://discuss.elastic.co/t/ordering-results-by-terms-filter/36059/2 "2015-12-04T02:02:16Z")

</div>

Filters do not contribute to the ordering of the results. Is there a query  
as well?

If you want to sort based on the arbitrary contents of an array, it might  
be possible with a script. But that would be a hack. I would focus on  
achieving proper scoring with queries.

Ivan

---

<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:33pm UTC](https://discuss.elastic.co/t/ordering-results-by-terms-filter/36059/3 "2017-07-05T23:33:41Z")

</div>


