# How to display only TOP 10 of aggregate count in kibana?

**URL:** https://discuss.elastic.co/t/how-to-display-only-top-10-of-aggregate-count-in-kibana/180484
**Category:** Kibana
**Created:** [May 10, 2019, 5:13am UTC](https://discuss.elastic.co/t/how-to-display-only-top-10-of-aggregate-count-in-kibana/180484 "2019-05-10T05:13:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![JH82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jh82/32/45952_2.png) [@JH82](https://discuss.elastic.co/u/JH82)
#### Post date: [May 10, 2019, 5:13am UTC](https://discuss.elastic.co/t/how-to-display-only-top-10-of-aggregate-count-in-kibana/180484/1 "2019-05-10T05:13:22Z")

</div>

hello,

I use elastic cloud 7.x and I try to limit aggregate count to retreive only TOP 10 / per day (not all results)

I use this query, but it is so slow.... :  
{  
"aggs": {  
"2": {  
"date\_histogram": {  
"field": "emailInfo.mailProcessingStartTime",  
"interval": "1h",  
"time\_zone": "Europe/Paris",  
"min\_doc\_count": 1  
},  
"aggs": {  
"6": {  
"terms": {  
"field": "emailInfo.headerFrom.keyword",  
"size": 5,  
"order": {  
"\_count": "desc"  
}  
}  
}  
}  
}  
},  
"size": 0,  
"\_source": {  
"excludes":   
},  
"stored\_fields": [  
"\*"  
],  
"script\_fields": {},  
"docvalue\_fields": [  
{  
"field": "emailInfo.mailProcessingStartTime",  
"format": "date\_time"  
}  
],  
"query": {  
"bool": {  
"must": ,  
"filter": [  
{  
"match\_all": {}  
},  
{  
"match\_all": {}  
}  
],  
"should": ,  
"must\_not":   
}  
}  
}

Thanks for your help !

---

<div class="post-metadata">

### Author: ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)
#### Post date: [May 24, 2019, 2:11pm UTC](https://discuss.elastic.co/t/how-to-display-only-top-10-of-aggregate-count-in-kibana/180484/2 "2019-05-24T14:11:47Z")

</div>

Hi,

so that is basically the right and only query to use if you want to visualize TOP 5 / per day. ES is actually bucketing all your data into 1h buckets, and than it applies the term aggregation.

It's slow because it first looks at all your data, aggregate everything by 1h buckets and than apply the other agg.

That speed depends also on various factors: time window of your query, data volume, and for sure on you actual cluster configuration. Can you tell me a bit more of those 3 factors?

---

<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: [June 21, 2019, 2:11pm UTC](https://discuss.elastic.co/t/how-to-display-only-top-10-of-aggregate-count-in-kibana/180484/3 "2019-06-21T14:11:47Z")

</div>

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