ElasticSearch - ordering aggregation by nested aggregation by nested field

{ "query": { "match_all": {} }, "from": 0, "size": 0, "aggs": { "itineraryId": { "terms": { "field": "iid", "size": 2147483647, "order": [ { "price>price>price.max": "desc" } ] }, "aggs": { "duration": { "stats": { "field": "drn" } }, "price": { "nested": { "path": "prl" }, "aggs": { "price": { "filter": { "terms": { "prl.cc.keyword": [ "USD" ] } }, "aggs": { "price": { "stats": { "field": "prl.spl.vl" } } } } } } } } } } 

Here I get the error "Invalid way to streamline the aggregation of terms [price> price> price .max]. Terms carpets can only be sorted by the sub-aggregator path, which is built from zero or more odnokovshih clusters within the path and the final unit basket or aggregation of metrics at the end of the path. Subpath [price] indicates aggregation without a single cache "

the request works fine if I order aggregation by duration, for example

 "order": [ { "duration.max": "desc" } 

So, is there a way to order aggregation by nested aggregation on a nested field ie something like below?

 "order": [ { "price>price>price.max": "desc" } 
+1
source share
1 answer

As Val noted, ES is not yet supported in the comments.

Prior to this, you can first aggregate nested aggregation and then use reverse nested aggregation to aggregate the duration that is present in the root document.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html

0
source

All Articles