# Convert strings to floats/ints at aggregation time?

**URL:** <https://discuss.elastic.co/t/convert-strings-to-floats-ints-at-aggregation-time/19345>\
**Category:** Elasticsearch\
**Created:** [August 19, 2014, 6:29pm UTC](https://discuss.elastic.co/t/convert-strings-to-floats-ints-at-aggregation-time/19345 "2014-08-19T18:29:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amol\_deshpande](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@amol\_deshpande](https://discuss.elastic.co/u/amol_deshpande)\
**Post date:** [August 19, 2014, 6:29pm UTC](https://discuss.elastic.co/t/convert-strings-to-floats-ints-at-aggregation-time/19345/1 "2014-08-19T18:29:28Z")

</div>

hi,

Is there any way to convert strings to floats (and ints) when specifying a  
terms or histogram aggregation ? I have documents with fields that are  
floats and ints but are not parsed by elasticsearch as such.

I know I could change the mapping, but for the usage case that I have  
(support extraction of arbitrary events from log files, just by specifying  
fields to index with simple regexes), it would be a lot more handy if I  
could specify something like "script : \_value.tofloat()" when writing the  
aggregation for the field.

thanks,  
-amol

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f0e63fde-2143-4c89-b2a7-491f95cdd044%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f0e63fde-2143-4c89-b2a7-491f95cdd044%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:07am UTC](https://discuss.elastic.co/t/convert-strings-to-floats-ints-at-aggregation-time/19345/2 "2017-07-06T01:07:39Z")

</div>


