# Changing the mapping of fields

**URL:** <https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050>\
**Category:** Elasticsearch\
**Created:** [July 21, 2016, 2:57am UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050 "2016-07-21T02:57:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkadapak](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bkadapak](https://discuss.elastic.co/u/bkadapak)\
**Post date:** [July 21, 2016, 2:57am UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/1 "2016-07-21T02:57:13Z")

</div>

Hi,  
I am using dynamic mapping for my indexes, since I'm not sure about the data format. If i want to change the datatype for field, then what are my options ? Mapping api doesn't support changing the data type.

Lets say I created a field called date with data type as "long", if i need to change the data type to string or even maybe an object. How can this be done ?

Thanks!

---

<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:** [July 21, 2016, 3:04am UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/2 "2016-07-21T03:04:49Z")

</div>

You need to reindex the data, you cannot change a field once it has been set.

---

<div class="post-metadata">

**Author:** ![bkadapak](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bkadapak](https://discuss.elastic.co/u/bkadapak)\
**Post date:** [July 21, 2016, 3:16am UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/3 "2016-07-21T03:16:39Z")

</div>

When you say reindexing, you mean moving all the data from my current index to new index. Is that right?  
This will cause the application to be down for quite sometime. Is that the only option ?

---

<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:** [July 21, 2016, 3:18am UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/4 "2016-07-21T03:18:04Z")

</div>

> [@bkadapak](#):
>
> When you say reindexing, you mean moving all the data from my current index to new index. Is that right?

Yes.

> [@bkadapak](#):
>
> This will cause the application to be down for quite sometime.

Why? Check out [Changing Mapping with Zero Downtime | Elastic Blog](https://www.elastic.co/blog/changing-mapping-with-zero-downtime)

---

<div class="post-metadata">

**Author:** ![bkadapak](https://avatars.discourse-cdn.com/v4/letter/b/eada6e/32.png) [@bkadapak](https://discuss.elastic.co/u/bkadapak)\
**Post date:** [July 21, 2016, 3:30am UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/5 "2016-07-21T03:30:44Z")

</div>

Thanks for the quick reply. Changes suggested in this above are valid for version 2.3 as well, right ?

---

<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:** [July 21, 2016, 3:39am UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/6 "2016-07-21T03:39:07Z")

</div>

Yep!

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [July 28, 2016, 9:08am UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/7 "2016-07-28T09:08:51Z")

</div>

> Why? Check out [https://www.elastic.co/blog/changing-mapping-with-zero-downtime4](https://www.elastic.co/blog/changing-mapping-with-zero-downtime4)

What I don't understand about this is:  
If I have a field - currently `metadata.url.path` (as inserted into a status index by stormcrawler), and I re-index to be `metadata.url%2Epath` (to work with updated stormcrawler), stormcrawler is still looking for the field: `metadata.url.path`.

Even if I alias the status index and the new index and have stormcrawler look at the alias, the inconsistency of the fieldnames will mean that some records will work and some won't, am I right?

Or is there some way of telling the alias that, when querying, it should "rename" `metadata.url.path` to `metadata.url%2Epath`?

---

<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:** [July 28, 2016, 10:43pm UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/8 "2016-07-28T22:43:48Z")

</div>

Ahh, well then yes, you need to switch your underlying application code.  
There's no good way around that sorry.

---

<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 5, 2017, 10:31pm UTC](https://discuss.elastic.co/t/changing-the-mapping-of-fields/56050/9 "2017-07-05T22:31:56Z")

</div>


