# Reverse Nested Aggregation Sort

**URL:** https://discuss.elastic.co/t/reverse-nested-aggregation-sort/22831
**Category:** Elasticsearch
**Created:** [March 23, 2015, 4:52pm UTC](https://discuss.elastic.co/t/reverse-nested-aggregation-sort/22831 "2015-03-23T16:52:54Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![JZ1](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@JZ1](https://discuss.elastic.co/u/JZ1)
#### Post date: [March 23, 2015, 4:52pm UTC](https://discuss.elastic.co/t/reverse-nested-aggregation-sort/22831/1 "2015-03-23T16:52:54Z")

</div>

Hi all,

I am wondering whether it is possible to sort a reverse nested aggregation  
by the document count of the joined root / document the nested object  
belongs to. The counts of the nested objects and the root document counts  
can be off.

I was hoping it is possible to do this in ES and not by double traversing  
the array to get the sort order by document count right.

Thanks in advance!

/JZ

--  
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/CAA%2BD3eV2qDcXNd\_tNCE%2B6XtP5Kt\_uuAd0yhC7OjW0xxcWZAVBA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAA%2BD3eV2qDcXNd_tNCE%2B6XtP5Kt_uuAd0yhC7OjW0xxcWZAVBA%40mail.gmail.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:24am UTC](https://discuss.elastic.co/t/reverse-nested-aggregation-sort/22831/2 "2017-07-06T00:24:45Z")

</div>


