# Changing datatype

**URL:** <https://discuss.elastic.co/t/changing-datatype/70520>\
**Category:** Elasticsearch\
**Created:** [January 4, 2017, 7:30am UTC](https://discuss.elastic.co/t/changing-datatype/70520 "2017-01-04T07:30:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thanigaivelan19](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@thanigaivelan19](https://discuss.elastic.co/u/thanigaivelan19)\
**Post date:** [January 4, 2017, 7:30am UTC](https://discuss.elastic.co/t/changing-datatype/70520/1 "2017-01-04T07:30:00Z")

</div>

Hi,

How can we change the mapped data type , from string to integer.

$ curl -XPUT '[http://localhost:9200/songs/song/\_mapping](http://localhost:9200/songs/song/_mapping)' -d '  
{  
"song" : {  
"properties" : {  
"position" : {"type" : "integer"}  
}  
}  
}

When i had tried this, i am getting error

{"error":{"root\_cause":[{"type":"illegal\_argument\_exception","reason":"mapper [position] cannot be changed from type [string] to [int]"}],"type":"illegal\_argument\_exception","reason":"mapper [position] cannot be changed from type [string] to [int]"},"status":400}

Thanks

Thanigaivelan

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 4, 2017, 7:35am UTC](https://discuss.elastic.co/t/changing-datatype/70520/2 "2017-01-04T07:35:40Z")

</div>

You need to reindex the data, you cannot just change it.

---

<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 1, 2017, 7:36am UTC](https://discuss.elastic.co/t/changing-datatype/70520/3 "2017-02-01T07:36:05Z")

</div>

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