# Using a bucket key for filtering in the according aggregation

**URL:** <https://discuss.elastic.co/t/using-a-bucket-key-for-filtering-in-the-according-aggregation/291423>\
**Category:** Elasticsearch\
**Created:** [December 10, 2021, 12:27pm UTC](https://discuss.elastic.co/t/using-a-bucket-key-for-filtering-in-the-according-aggregation/291423 "2021-12-10T12:27:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Zahn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marc_zahn/32/44302_2.png) [@Marc\_Zahn](https://discuss.elastic.co/u/Marc_Zahn)\
**Post date:** [December 10, 2021, 12:27pm UTC](https://discuss.elastic.co/t/using-a-bucket-key-for-filtering-in-the-according-aggregation/291423/1 "2021-12-10T12:27:10Z")

</div>

Hello,

maybe I searched for the wrong things, but I have a problem and don't know if it is possible to solve it: I have a terms aggregation where I need to filter the documents by matching the bucket keys against an input.

Here: [Access to the date\_histogram buckets key to the next level aggregation or bucket\_script · Issue #56392 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/56392) they say it's not possible to use data from an outer aggregation within an inner aggregation.

But is it possible to use the bucket key for a filter in the same 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:** [January 7, 2022, 12:27pm UTC](https://discuss.elastic.co/t/using-a-bucket-key-for-filtering-in-the-according-aggregation/291423/2 "2022-01-07T12:27:31Z")

</div>

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