elasticsearch/elasticsearch — pull request #5340 by uboness (2014-03-05 00:46:57+00:00)
Title: Added support for sorting buckets based on sub aggregation down the curr...

...ent hierarchy. This is supported as long as the aggregation in the specified order path are of a single-bucket type, where the last aggregation in the path points to either a single-bucket aggregation or a metrics one. If it's a single-bucket aggregation, the sort will be applied on the document count in the bucket (i.e. doc_count), and if it is a metrics type, the sort will be applied on the pointed out metric (in case of a single-metric aggregations, such as avg, the sort will be applied on the single metric value)

Closes #5253