# Can I use previous aggregation key in a script?

**URL:** <https://discuss.elastic.co/t/can-i-use-previous-aggregation-key-in-a-script/103908>\
**Category:** Elasticsearch\
**Created:** [October 13, 2017, 1:51pm UTC](https://discuss.elastic.co/t/can-i-use-previous-aggregation-key-in-a-script/103908 "2017-10-13T13:51:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cristinalazin](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@cristinalazin](https://discuss.elastic.co/u/cristinalazin)\
**Post date:** [October 13, 2017, 1:51pm UTC](https://discuss.elastic.co/t/can-i-use-previous-aggregation-key-in-a-script/103908/1 "2017-10-13T13:51:32Z")

</div>

I have a chain of Bucketing Aggregations. Inside I want to apply a Filter Aggregation having the must bool condition defined by a script.

The filter condition should depend on the value of one bucket key from the chain.

Is it possible to define a script parameter that holds the key of a parent aggregation?

---

<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 10, 2017, 1:52pm UTC](https://discuss.elastic.co/t/can-i-use-previous-aggregation-key-in-a-script/103908/2 "2017-11-10T13:52:16Z")

</div>

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