# How do I compute bucket size distribution?

**URL:** <https://discuss.elastic.co/t/how-do-i-compute-bucket-size-distribution/198857>\
**Category:** Elasticsearch\
**Created:** [September 10, 2019, 9:22am UTC](https://discuss.elastic.co/t/how-do-i-compute-bucket-size-distribution/198857 "2019-09-10T09:22:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matteo\_Grolla](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matteo_grolla/32/48451_2.png) [@Matteo\_Grolla](https://discuss.elastic.co/u/Matteo_Grolla)\
**Post date:** [September 10, 2019, 9:22am UTC](https://discuss.elastic.co/t/how-do-i-compute-bucket-size-distribution/198857/1 "2019-09-10T09:22:06Z")

</div>

I'd like to group documents by a field (cluster\_id) and find the distribution of group sizes  
Ex:  
200 groups have size 1  
150 have size 2  
...  
50 have size 30  
I tried with

{  
"size": 0,  
"aggs" : {  
"clusters": { "terms" : { "field": "selection.cluster\_id", "size": 1000 } },  
"stats\_cluster": {  
"stats\_bucket": { "buckets\_path": "clusters\>\_count" }  
}  
}  
}

but selection.cluster\_id cardinality is 3M, and don't need the huge bucket list in the result

---

<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:** [October 8, 2019, 9:22am UTC](https://discuss.elastic.co/t/how-do-i-compute-bucket-size-distribution/198857/2 "2019-10-08T09:22:07Z")

</div>

Closed on October 8, 2019, 9:22am UTC

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