# Convert fields of datatype text to int or float in Kibana

**URL:** <https://discuss.elastic.co/t/convert-fields-of-datatype-text-to-int-or-float-in-kibana/194324>\
**Category:** Kibana\
**Created:** [August 7, 2019, 8:43pm UTC](https://discuss.elastic.co/t/convert-fields-of-datatype-text-to-int-or-float-in-kibana/194324 "2019-08-07T20:43:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [August 8, 2019, 8:31am UTC](https://discuss.elastic.co/t/convert-fields-of-datatype-text-to-int-or-float-in-kibana/194324/2 "2019-08-08T08:31:16Z")

</div>

You can convert data real time using scripted fields but the performance implications are huge (it will be a lot slower than having those fields indexed as correct data type)

> **[Using Painless in Kibana scripted fields](https://www.elastic.co/blog/using-painless-kibana-scripted-fields)**

> [@Painscript Script - cast String as Int?](https://discuss.elastic.co/t/painscript-script-cast-string-as-int/97034):
>
> We have a mapping issue that will be addressed soon for a field that should be an int but is presently a string. All values in the index should cast cleanly. Anyhow, in a pinch I wanted to aggregate some data on the field and thought creating a scripted field in K5 would be a temp solution. Can anyone point me in the right direction or provide a code example? I tried several things including (int)['doc.myfield'].value and also parseInt(string) as documented at [https://docs.oracle.com/javase/…](https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#parseInt%2Djava.lang.String%2D)

---

_[View the full topic](https://discuss.elastic.co/t/convert-fields-of-datatype-text-to-int-or-float-in-kibana/194324)._
