# Ordering in sub-sub aggregation bucket

**URL:** https://discuss.elastic.co/t/ordering-in-sub-sub-aggregation-bucket/14908
**Category:** Elasticsearch
**Created:** [December 17, 2013, 10:06am UTC](https://discuss.elastic.co/t/ordering-in-sub-sub-aggregation-bucket/14908 "2013-12-17T10:06:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Konstantinos\_Zachara](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/konstantinos_zachara/32/1887_2.png) [@Konstantinos\_Zachara](https://discuss.elastic.co/u/Konstantinos_Zachara)
#### Post date: [December 17, 2013, 10:06am UTC](https://discuss.elastic.co/t/ordering-in-sub-sub-aggregation-bucket/14908/1 "2013-12-17T10:06:14Z")

</div>

Hello,

We are currently evaluating the aggregations api and we have reached into a  
point where we are trying to sort the buckets returned by a stats  
aggregation which is in depth 4.

However executing the following search we receive a NPE.

POST \_search?search\_type=count  
{  
"aggregations": {  
"issueName\_bucket": {  
"terms": {  
"field": "issueName",  
"order": {  
"stats\_bucket.avg": "asc"  
}  
},  
"aggregations": {  
"destinationPage\_bucket": {  
"terms": {  
"field": "destinationPage"  
},  
"aggregations": {  
"over\_time\_bucket": {  
"date\_histogram": {  
"field": "timestamp",  
"interval": "day"  
},  
"aggregations": {  
"stats\_bucket": {  
"stats": {  
"field": "duration"  
}  
}  
}  
}  
}  
}  
}  
}  
}  
}

Does the aggregation api supports ordering sub aggregations of other sub  
aggregations?

Thanks is advance  
Kostas

--  
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/4bf525da-30ef-4feb-87c4-433e2fa80f6b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4bf525da-30ef-4feb-87c4-433e2fa80f6b%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:00am UTC](https://discuss.elastic.co/t/ordering-in-sub-sub-aggregation-bucket/14908/2 "2017-07-06T02:00:40Z")

</div>


