# Best practice for aggs query

**URL:** <https://discuss.elastic.co/t/best-practice-for-aggs-query/182466>\
**Category:** Elasticsearch\
**Created:** [May 23, 2019, 2:26pm UTC](https://discuss.elastic.co/t/best-practice-for-aggs-query/182466 "2019-05-23T14:26:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![klaus82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klaus82/32/45900_2.png) [@klaus82](https://discuss.elastic.co/u/klaus82)\
**Post date:** [May 23, 2019, 2:26pm UTC](https://discuss.elastic.co/t/best-practice-for-aggs-query/182466/1 "2019-05-23T14:26:09Z")

</div>

In aggs query, if I want to have:  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 0,  
or very small.  
Is a good practice to run before, the aggs query, another query to have the number of hits and the set this value in the "size" aggs query field? Or there is a better strategy?

---

<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 20, 2019, 2:26pm UTC](https://discuss.elastic.co/t/best-practice-for-aggs-query/182466/2 "2019-06-20T14:26:12Z")

</div>

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