# Round the values returned by facets

**URL:** <https://discuss.elastic.co/t/round-the-values-returned-by-facets/6968>\
**Category:** Elasticsearch\
**Created:** [March 12, 2012, 1:48pm UTC](https://discuss.elastic.co/t/round-the-values-returned-by-facets/6968 "2012-03-12T13:48:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yehuda\_Zargarov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yehuda_zargarov/32/2164_2.png) [@Yehuda\_Zargarov](https://discuss.elastic.co/u/Yehuda_Zargarov)\
**Post date:** [March 12, 2012, 1:48pm UTC](https://discuss.elastic.co/t/round-the-values-returned-by-facets/6968/1 "2012-03-12T13:48:23Z")

</div>

Is it possible to perform a query which returns floating values  
rounded by x places after the points?

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [March 12, 2012, 2:24pm UTC](https://discuss.elastic.co/t/round-the-values-returned-by-facets/6968/2 "2012-03-12T14:24:32Z")

</div>

It's possible to modify the value of the fields you are calculating facets  
on using term scripts  
([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html))

For example, the following query will return facets with floating values in  
the my\_field field rounded by 2 decimal places.

{  
"size" : 0,  
"query" : { "query\_string" : {"query" : "_:_"} },  
"facets" : {  
"from" : {  
"terms" : {  
"field" : "my\_field",  
"script": "round(term\*100)/100"  
}  
}  
}  
}

Igor Motov

On Monday, March 12, 2012 9:48:23 AM UTC-4, Yehuda Zargarov wrote:

> Is it possible to perform a query which returns floating values  
> rounded by x places after the points?

---

<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 6, 2017, 3:36am UTC](https://discuss.elastic.co/t/round-the-values-returned-by-facets/6968/3 "2017-07-06T03:36:22Z")

</div>


