# Term aggregation on all document

**URL:** <https://discuss.elastic.co/t/term-aggregation-on-all-document/282665>\
**Category:** Elasticsearch\
**Created:** [August 27, 2021, 12:23pm UTC](https://discuss.elastic.co/t/term-aggregation-on-all-document/282665 "2021-08-27T12:23:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![glefloch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/glefloch/32/93821_2.png) [@glefloch](https://discuss.elastic.co/u/glefloch)\
**Post date:** [August 27, 2021, 12:23pm UTC](https://discuss.elastic.co/t/term-aggregation-on-all-document/282665/1 "2021-08-27T12:23:52Z")

</div>

Hi,

I'm working with Elasticsearch and I would like to be able to do something like:

- Grouping documents into a bucket depending on a field
- Computing on an other field
- Using a `percentile_bucket` aggregation to get the repartition of those max.
- Showing the repartition in a geotile grid

I have a beginning of a solution:

```auto
"aggs": {
    "grid": {
      "geotile_grid": {
        "field": "position",
        "precision": 10.7053792511084
      },
      "aggs": {
         "center": {
          "geo_centroid": {
            "field": "position"
          }
        },
        "grouping-path": {
          "terms": {
            "field": "context.keyword",
            "size": 10000
          },
          "aggs": {
            "max": {
              "min": {
                "field": "some_field"
              }
            }
          }
        },
        "repartition": {
          "percentiles_bucket": {
            "buckets_path": "grouping-path>max"
          }
        }
      }
    }
  }

```

As you can see, the term aggregation will have a limit. And, in my case, there may be more than 10000 different documents per tile. Is there a way to do something else?

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:** [September 24, 2021, 12:23pm UTC](https://discuss.elastic.co/t/term-aggregation-on-all-document/282665/2 "2021-09-24T12:23:56Z")

</div>

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