# Multisort on terms aggregation

**URL:** <https://discuss.elastic.co/t/multisort-on-terms-aggregation/22494>\
**Category:** Elasticsearch\
**Created:** [March 3, 2015, 5:00pm UTC](https://discuss.elastic.co/t/multisort-on-terms-aggregation/22494 "2015-03-03T17:00:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Demetrioca](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/demetrioca/32/856_2.png) [@Demetrioca](https://discuss.elastic.co/u/Demetrioca)\
**Post date:** [March 3, 2015, 5:00pm UTC](https://discuss.elastic.co/t/multisort-on-terms-aggregation/22494/1 "2015-03-03T17:00:15Z")

</div>

Is there a way to do a sorting by multiple metrics in the terms  
aggregations?  
Here's the way I tried: [https://gist.github.com/2e3s/599330bfef10e9375f6f](https://gist.github.com/2e3s/599330bfef10e9375f6f)  
and this doesn't work.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f259c8ce-ac62-487b-af1c-21a19e230eac%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f259c8ce-ac62-487b-af1c-21a19e230eac%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [March 4, 2015, 8:39am UTC](https://discuss.elastic.co/t/multisort-on-terms-aggregation/22494/2 "2015-03-04T08:39:58Z")

</div>

In the currently released versions it is not possible to sort by multiple  
criteria in the terms aggregations. This  
functionality is coming in 1.5 from this PR:  
[Add ability to sort on multiple criteria by colings86 · Pull Request #7662 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/7662).

The syntax will be a bit different from what you tried in your gist. have a  
look  
at [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-order)  
to see the syntax that is coming in 1.5 for this.

Colin

On Tuesday, 3 March 2015 17:00:15 UTC, Demetrioca wrote:

> Is there a way to do a sorting by multiple metrics in the terms  
> aggregations?  
> Here's the way I tried: [gist:599330bfef10e9375f6f · GitHub](https://gist.github.com/2e3s/599330bfef10e9375f6f)  
> and this doesn't work.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/614fd9a1-5c88-4cd2-9596-b01a5d47cdad%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/614fd9a1-5c88-4cd2-9596-b01a5d47cdad%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:28am UTC](https://discuss.elastic.co/t/multisort-on-terms-aggregation/22494/3 "2017-07-06T00:28:40Z")

</div>


