# Range aggregation in a pipeline aggregation

**URL:** <https://discuss.elastic.co/t/range-aggregation-in-a-pipeline-aggregation/201768>\
**Category:** Elasticsearch\
**Created:** [October 1, 2019, 9:49am UTC](https://discuss.elastic.co/t/range-aggregation-in-a-pipeline-aggregation/201768 "2019-10-01T09:49:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uzo/32/45305_2.png) [@Uzo](https://discuss.elastic.co/u/Uzo)\
**Post date:** [October 1, 2019, 9:49am UTC](https://discuss.elastic.co/t/range-aggregation-in-a-pipeline-aggregation/201768/1 "2019-10-01T09:49:59Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/uzo/32/45305_2.png) [@Uzo](https://discuss.elastic.co/u/Uzo)\
**Post date:** [October 4, 2019, 12:08pm UTC](https://discuss.elastic.co/t/range-aggregation-in-a-pipeline-aggregation/201768/2 "2019-10-04T12:08:47Z")

</div>

What I am asking for seems not implemented ([https://github.com/elastic/elasticsearch/issues/17590](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.

---

<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:** [November 1, 2019, 12:09pm UTC](https://discuss.elastic.co/t/range-aggregation-in-a-pipeline-aggregation/201768/3 "2019-11-01T12:09:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
