# Number Precision

**URL:** <https://discuss.elastic.co/t/number-precision/114996>\
**Category:** Elasticsearch\
**Created:** [January 11, 2018, 3:59am UTC](https://discuss.elastic.co/t/number-precision/114996 "2018-01-11T03:59:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![karnamonkster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karnamonkster/32/67266_2.png) [@karnamonkster](https://discuss.elastic.co/u/karnamonkster)\
**Post date:** [January 11, 2018, 3:59am UTC](https://discuss.elastic.co/t/number-precision/114996/1 "2018-01-11T03:59:41Z")

</div>

Hi,

I am facing an issue with the number precision.  
We have a field "consumptionvalue" as float which contains numeric values like 0.001, 0.004, 0.054 etc.  
When i try to search for records with below query  
**consumptionvalue:[0 TO 1]**  
I still get the values out of this range(+ve).

Is there anything else that we need to do to address this precision issue.

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 11, 2018, 4:05am UTC](https://discuss.elastic.co/t/number-precision/114996/2 "2018-01-11T04:05:25Z")

</div>

Is it conceivable for you to change your type and use `scaled_float` with a `scaling_factor` of 1000 instead? That way 0.001 would be stored as 1, 0.054 as 54 and the range queries will become queries on integer numbers, hence much more precise. Can you give it a shot?

---

<div class="post-metadata">

**Author:** ![karnamonkster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karnamonkster/32/67266_2.png) [@karnamonkster](https://discuss.elastic.co/u/karnamonkster)\
**Post date:** [January 11, 2018, 9:02am UTC](https://discuss.elastic.co/t/number-precision/114996/3 "2018-01-11T09:02:08Z")

</div>

Thanks, I have fixed it by changing the type and works fine , for some reason the first record say with value was streamed in as “ **long** “ and hence the mapping for all the values were of type long.  
I enabled the mapping as “float” and hence worked  
Thanks for your help

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 11, 2018, 9:12am UTC](https://discuss.elastic.co/t/number-precision/114996/4 "2018-01-11T09:12:36Z")

</div>

Yes, that can also be the reason. Glad you figured it out!

---

<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:** [February 8, 2018, 9:12am UTC](https://discuss.elastic.co/t/number-precision/114996/5 "2018-02-08T09:12:57Z")

</div>

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