# Terms Aggregation Partitioning + filter buckets

**URL:** <https://discuss.elastic.co/t/terms-aggregation-partitioning-filter-buckets/261550>\
**Category:** Elasticsearch\
**Created:** [January 19, 2021, 1:40pm UTC](https://discuss.elastic.co/t/terms-aggregation-partitioning-filter-buckets/261550 "2021-01-19T13:40:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nam\_Nguyen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nam_nguyen/32/82540_2.png) [@Nam\_Nguyen](https://discuss.elastic.co/u/Nam_Nguyen)\
**Post date:** [January 19, 2021, 1:40pm UTC](https://discuss.elastic.co/t/terms-aggregation-partitioning-filter-buckets/261550/1 "2021-01-19T13:40:05Z")

</div>

Hey 👋,

## Context

I am currently struggling to create a proper query for the following use case.  
Let's say I wanted to create a group-by aggregation for e.g. term `app:.*`, I would do the following:

```auto
          "terms": {
            "field": "tags",
            "include": "app:.*",
            "size": 300000
          }

```

This would give me all buckets which matches the regex.

## Why

I have some high cardinality fields + nested terms aggregations which can trip the circuit breaker

## Questions

I have the following questions:

How can I combine above with partitioning? AFAICT it is not possible to filter what kind of buckets we will create and therefore for every tag a bucket is created. Is there a way to filter it like above?  
Something like this?

```auto
          "terms": {
            "field": "tags",
            "include_regexp": "app:.*",
"include":{"partition":0, "num_partitions": 100}
            "size": 300000
          } 

```

Does ES recomputate the partitions each time we query them e.g. `partition:1` and the next query `partition:3` or does it somehow cache the values?

Thanks 🙇‍♂️

---

<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:** [February 16, 2021, 1:40pm UTC](https://discuss.elastic.co/t/terms-aggregation-partitioning-filter-buckets/261550/2 "2021-02-16T13:40:15Z")

</div>

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