# Data Type Conversion of a Field

**URL:** <https://discuss.elastic.co/t/data-type-conversion-of-a-field/78307>\
**Category:** Elasticsearch\
**Created:** [March 13, 2017, 6:46am UTC](https://discuss.elastic.co/t/data-type-conversion-of-a-field/78307 "2017-03-13T06:46:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![prakash1243](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@prakash1243](https://discuss.elastic.co/u/prakash1243)\
**Post date:** [March 13, 2017, 6:46am UTC](https://discuss.elastic.co/t/data-type-conversion-of-a-field/78307/1 "2017-03-13T06:46:02Z")

</div>

Hi -  
I have consumed a community beat (wmibeat) and running fine and sending the data directly to the Elastic search engine. There are few fields which are been with 'String' data type, even though we get a numeric value. So I couldn't able to perform any aggregation with those fields.

Would you please let me know, how do I change the data type of a field from String to Number. Please let me know.

Thanks !

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 13, 2017, 9:18pm UTC](https://discuss.elastic.co/t/data-type-conversion-of-a-field/78307/2 "2017-03-13T21:18:00Z")

</div>

Hey,

you cannot change fields or its type after data has been indexed. In order to not hit this in the future, you should make sure, that you have an [index template](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/indices-templates.html) configured, that changes those fields to numeric fields.

--Alex

---

<div class="post-metadata">

**Author:** ![prakash1243](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@prakash1243](https://discuss.elastic.co/u/prakash1243)\
**Post date:** [March 15, 2017, 9:49am UTC](https://discuss.elastic.co/t/data-type-conversion-of-a-field/78307/3 "2017-03-15T09:49:17Z")

</div>

Thanks for your reply, @spinscale.

I have tried deploying the Index template, it changes the data type format, but if we restart the service, the Indexes are getting back to the old data type. Is there any way we can change the data type permanently? so that new indexes would work fine. Please let me know. Thanks !

---

<div class="post-metadata">

**Author:** ![prakash1243](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@prakash1243](https://discuss.elastic.co/u/prakash1243)\
**Post date:** [March 20, 2017, 5:15am UTC](https://discuss.elastic.co/t/data-type-conversion-of-a-field/78307/4 "2017-03-20T05:15:55Z")

</div>

Could some one please help me out here... Thanks !

---

<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:** [April 17, 2017, 5:16am UTC](https://discuss.elastic.co/t/data-type-conversion-of-a-field/78307/5 "2017-04-17T05:16:00Z")

</div>

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