# Ordering Significant Terms aggregation?

**URL:** <https://discuss.elastic.co/t/ordering-significant-terms-aggregation/27570>\
**Category:** Elasticsearch\
**Created:** [August 18, 2015, 9:17am UTC](https://discuss.elastic.co/t/ordering-significant-terms-aggregation/27570 "2015-08-18T09:17:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnaud\_Cassaigne](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Arnaud\_Cassaigne](https://discuss.elastic.co/u/Arnaud_Cassaigne)\
**Post date:** [August 18, 2015, 9:17am UTC](https://discuss.elastic.co/t/ordering-significant-terms-aggregation/27570/1 "2015-08-18T09:17:32Z")

</div>

Hello,

I'd like to order the results of a Significant Terms aggregation by descending count.

It is possible to specify: "order": { "\_count" : "desc" } for a Terms aggregation but the key "order" is not recognized for a Significant Terms aggregation.

Any ideas ?

Best regards,  
Arnaud

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [August 18, 2015, 10:19am UTC](https://discuss.elastic.co/t/ordering-significant-terms-aggregation/27570/2 "2015-08-18T10:19:23Z")

</div>

The Significant Terms aggregation does not currently have the ability to define order, the buckets are returned in order of descending significance score. If you would like to see this feature I would suggest raising an issue on the [issue list of the Elasticearch Github repository](https://github.com/elastic/elasticsearch/issues) or if you fancy having a go at implementing the feature yourself and contributing it back to the project, raise a [Pull Request](https://github.com/elastic/elasticsearch/pulls) with your code changes.

HTH

---

<div class="post-metadata">

**Author:** ![Arnaud\_Cassaigne](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Arnaud\_Cassaigne](https://discuss.elastic.co/u/Arnaud_Cassaigne)\
**Post date:** [August 18, 2015, 10:50am UTC](https://discuss.elastic.co/t/ordering-significant-terms-aggregation/27570/3 "2015-08-18T10:50:13Z")

</div>

Hello Colin,

thanks for your response ! It confirms what I expected.

Do you think there is a workaround ? Something like having a ES query with two nested levels: first the Significant Terms aggregation and then the ordering ?

Thank you,  
Arnaud

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [August 18, 2015, 11:31am UTC](https://discuss.elastic.co/t/ordering-significant-terms-aggregation/27570/4 "2015-08-18T11:31:31Z")

</div>

The only workaround would be to retrieve the buckets in your application and perform the sorting there.

---

<div class="post-metadata">

**Author:** ![Arnaud\_Cassaigne](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Arnaud\_Cassaigne](https://discuss.elastic.co/u/Arnaud_Cassaigne)\
**Post date:** [August 18, 2015, 12:17pm UTC](https://discuss.elastic.co/t/ordering-significant-terms-aggregation/27570/5 "2015-08-18T12:17:15Z")

</div>

ok, thanks for your explanations.

Arnaud

---

<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:55pm UTC](https://discuss.elastic.co/t/ordering-significant-terms-aggregation/27570/6 "2017-07-05T23:55:20Z")

</div>


