# How can i improve accuracy of term aggregation?

**URL:** <https://discuss.elastic.co/t/how-can-i-improve-accuracy-of-term-aggregation/127588>\
**Category:** Kibana\
**Created:** [April 11, 2018, 8:14am UTC](https://discuss.elastic.co/t/how-can-i-improve-accuracy-of-term-aggregation/127588 "2018-04-11T08:14:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![meetdave2611997](https://avatars.discourse-cdn.com/v4/letter/m/f07891/32.png) [@meetdave2611997](https://discuss.elastic.co/u/meetdave2611997)\
**Post date:** [April 11, 2018, 8:14am UTC](https://discuss.elastic.co/t/how-can-i-improve-accuracy-of-term-aggregation/127588/1 "2018-04-11T08:14:44Z")

</div>

Hello,

I am creating visualizations in which term aggregation is not showing accurate values. How can i increase accuracy and make it exact value so that i can have proper visualization?

Thank You,  
Meet

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [April 11, 2018, 5:15pm UTC](https://discuss.elastic.co/t/how-can-i-improve-accuracy-of-term-aggregation/127588/2 "2018-04-11T17:15:24Z")

</div>

Hey @meetdave2611997 the following article explains the way document counts are calculated for the terms aggregation: [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-approximate-counts](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html#search-aggregations-bucket-terms-aggregation-approximate-counts) and what can be done to improve the situation

---

<div class="post-metadata">

**Author:** ![meetdave2611997](https://avatars.discourse-cdn.com/v4/letter/m/f07891/32.png) [@meetdave2611997](https://discuss.elastic.co/u/meetdave2611997)\
**Post date:** [April 12, 2018, 5:18am UTC](https://discuss.elastic.co/t/how-can-i-improve-accuracy-of-term-aggregation/127588/3 "2018-04-12T05:18:16Z")

</div>

So this is dynamic solution right? for example i have specified `shard_size: 500` and it is showing correct results for last 15 days. But what if someone searches data for last 30 days. this value would not work. In that case what should i do?

Thank You,  
Meet

---

<div class="post-metadata">

**Author:** ![Brandon\_Kobel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brandon_kobel/32/14829_2.png) [@Brandon\_Kobel](https://discuss.elastic.co/u/Brandon_Kobel)\
**Post date:** [April 12, 2018, 12:45pm UTC](https://discuss.elastic.co/t/how-can-i-improve-accuracy-of-term-aggregation/127588/4 "2018-04-12T12:45:03Z")

</div>

@meetdave2611997 you could potentially hard-code the shard\_size to a large enough number that it gives you exact results for all expected query parameters; however, this definitely isn't ideal.

Unfortunately, this is one of the trade-offs that Elasticsearch has made to support these types of queries against really large data-sets, so there isn't a scalable way to ensure that this value is exact without trading off memory usage within the cluster.

---

<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:** [May 10, 2018, 12:45pm UTC](https://discuss.elastic.co/t/how-can-i-improve-accuracy-of-term-aggregation/127588/5 "2018-05-10T12:45:10Z")

</div>

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