# Get aggregation bucket size with a min\_doc\_count

**URL:** <https://discuss.elastic.co/t/get-aggregation-bucket-size-with-a-min-doc-count/77146>\
**Category:** Elasticsearch\
**Created:** [March 2, 2017, 1:38pm UTC](https://discuss.elastic.co/t/get-aggregation-bucket-size-with-a-min-doc-count/77146 "2017-03-02T13:38:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Croenne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_croenne/32/16014_2.png) [@David\_Croenne](https://discuss.elastic.co/u/David_Croenne)\
**Post date:** [March 2, 2017, 1:38pm UTC](https://discuss.elastic.co/t/get-aggregation-bucket-size-with-a-min-doc-count/77146/1 "2017-03-02T13:38:25Z")

</div>

Hello,

I have an index in which I store mail metadata (sender ip, subject etc.) What I'm trying to do is I want to get number of IPs which send over 1000 mails. (So for example let's say we have 3 IP addresses, 2000 mails are sent from first IP, 1500 from second and 200 from the third IP. Then I want to see 2 as the aggregation result.) I wrote the following query:

GET /my\_index/\_search  
{  
"size": 0,  
"aggs": {  
"ipAddresses": {  
"terms": {  
"field": "senderIpAddress",  
"min\_doc\_count": 1000,  
"size" : 0  
}  
}

}  
}

I can get the bucket and calculate its size in my back-end implementation, however I need to get all the data in the bucket in order to do this. It is slow and I want to get the bucket size without getting all the data.

Question: how can I get the total size of aggregation bucket without retrieving the whole data?

Note : I want to see number of IP addresses more than 1000 mails are sent from. If I just make a simple cardinality, then at the end of the day we will count the IP addresses less than 1000 mails are sent from.

---

<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:** [March 30, 2017, 1:38pm UTC](https://discuss.elastic.co/t/get-aggregation-bucket-size-with-a-min-doc-count/77146/2 "2017-03-30T13:38:29Z")

</div>

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