# Aggregation always returns 0 with values smaller than .1

**URL:** <https://discuss.elastic.co/t/aggregation-always-returns-0-with-values-smaller-than-1/43424>\
**Category:** Elasticsearch\
**Created:** [March 3, 2016, 5:24pm UTC](https://discuss.elastic.co/t/aggregation-always-returns-0-with-values-smaller-than-1/43424 "2016-03-03T17:24:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drew\_Town](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drew_town/32/44829_2.png) [@Drew\_Town](https://discuss.elastic.co/u/Drew_Town)\
**Post date:** [March 3, 2016, 5:24pm UTC](https://discuss.elastic.co/t/aggregation-always-returns-0-with-values-smaller-than-1/43424/1 "2016-03-03T17:24:28Z")

</div>

Is there a way to adjust aggregation precision thresholds? If I run an aggregation on a value that is smaller than 0.1 it always returns 0. I would like it to not return 0.

For example if I run a max, sum or avg on the values 0.052, 0.047 and 0.025 Elasticsearch will return 0.

---

<div class="post-metadata">

**Author:** ![Drew\_Town](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drew_town/32/44829_2.png) [@Drew\_Town](https://discuss.elastic.co/u/Drew_Town)\
**Post date:** [March 4, 2016, 8:23pm UTC](https://discuss.elastic.co/t/aggregation-always-returns-0-with-values-smaller-than-1/43424/2 "2016-03-04T20:23:43Z")

</div>

Any ideas on this?

---

<div class="post-metadata">

**Author:** ![Luke\_Nezda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luke_nezda/32/47152_2.png) [@Luke\_Nezda](https://discuss.elastic.co/u/Luke_Nezda)\
**Post date:** [March 5, 2016, 7:27am UTC](https://discuss.elastic.co/t/aggregation-always-returns-0-with-values-smaller-than-1/43424/3 "2016-03-05T07:27:54Z")

</div>

Can you make a curl test showing this behavior? (See "Bug reports" in [https://github.com/elastic/elasticsearch/blob/master/.github/CONTRIBUTING.md](https://github.com/elastic/elasticsearch/blob/master/.github/CONTRIBUTING.md))

---

<div class="post-metadata">

**Author:** ![Drew\_Town](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drew_town/32/44829_2.png) [@Drew\_Town](https://discuss.elastic.co/u/Drew_Town)\
**Post date:** [March 7, 2016, 1:53pm UTC](https://discuss.elastic.co/t/aggregation-always-returns-0-with-values-smaller-than-1/43424/4 "2016-03-07T13:53:45Z")

</div>

After pulling my hair out over this I have finally resolved this. The issue was that when the summary statistics would come in and create the new index the first one always seemed to have a count of 0 and therefore 0s in mean, min, max and stddev. So, the mapping was getting created as a long rather than a float. I adjusted the template to force it to a float, deleted the old indices and everything looks to be working as expected now.

The weird part is that the discover page and json would return the full number with all the decimal places but when trying to use the long value in a mathematical (such as average or max) agg it seems to truncate it to 1 decimal place. So numbers larger than 0.1 _would_ show up but smaller numbers would show up as zero.

---

<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:** [July 5, 2017, 11:10pm UTC](https://discuss.elastic.co/t/aggregation-always-returns-0-with-values-smaller-than-1/43424/5 "2017-07-05T23:10:40Z")

</div>


