Range aggregation in a pipeline aggregation

Hello,

I want to do the following pipeline aggregation :

  • A term aggregation
  • For each term do an average aggregation (so here it's a sub aggregation)
  • Then do a range aggregation on the previous average values.

Right now the 2 first step are working well. But i have issues doing the third one. I am using pipeline aggregation so I am for example able in the third step do compute the average instead a renage aggregation. But i do not know how to do a range aggregation in a pipeline aggregation. And if i try to do a range aggregation as a sub aggregation I do not know how to refer the previous computed average.

If anyone undestands what I want to do can you describe me how to do it ?

What I am asking for seems not implemented (https://github.com/elastic/elasticsearch/issues/17590).

As describe in the issue there is a way to have a part of the result by doing a bucket selector. But is there a way to count the number of element in the result with Elasticsearch ? (I don't Elastcisearch to return the whole result as I only need the number by bucket so I would like to use a filter_path but for that i first need to count how many result there was)

Then we can do multiples bucket selector in the same requests to have all ranges.