# Changing Dynamic Mapping

**URL:** <https://discuss.elastic.co/t/changing-dynamic-mapping/79189>\
**Category:** Elasticsearch\
**Created:** [March 19, 2017, 11:51pm UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189 "2017-03-19T23:51:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dashwood](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dashwood](https://discuss.elastic.co/u/dashwood)\
**Post date:** [March 19, 2017, 11:51pm UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/1 "2017-03-19T23:51:14Z")

</div>

Hi,

I currently have 2 fields that need to be changed in my Elasticsearch.

They are the DOB (Date of Birth) and Phone number field.

Currently the phone field has the type "Long" and the DOB field has the type "Date"

When I index my data this doesn't work cause bot the DOB and Date data might have '-' or '+'.

So in the long run, I have to either change my dynamic mapping (which I think is possible but have no clue how to do) or reindex with the proper dynamic mapping?

What should be the type for these fields and should I reindex to a new index or change my dynamic mapping if possible.

Thank you in advanced

---

<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:** [March 20, 2017, 2:38am UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/2 "2017-03-20T02:38:43Z")

</div>

You need to reindex, you can't change something that has already been set,

---

<div class="post-metadata">

**Author:** ![dashwood](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dashwood](https://discuss.elastic.co/u/dashwood)\
**Post date:** [March 20, 2017, 1:23pm UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/3 "2017-03-20T13:23:26Z")

</div>

What should I use for the DOB and Phone number type? Also how would I reindex without any downtime

---

<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:** [March 20, 2017, 8:59pm UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/4 "2017-03-20T20:59:06Z")

</div>

The first one seems like a date, the second will depend on what the format looks like.

---

<div class="post-metadata">

**Author:** ![dashwood](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dashwood](https://discuss.elastic.co/u/dashwood)\
**Post date:** [March 21, 2017, 12:34am UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/5 "2017-03-21T00:34:12Z")

</div>

The date had dashes in them and the phone numbers often have the plus symbol and dashes.

With our current types Long and Date, Elasticsearch rejects this.

How should we go about the types?

---

<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:** [March 21, 2017, 5:42am UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/6 "2017-03-21T05:42:05Z")

</div>

You should normalise the dates into a proper format so ES can store them as dates.  
You should also normalise the phone numbers, strip out the + and -.

---

<div class="post-metadata">

**Author:** ![dashwood](https://avatars.discourse-cdn.com/v4/letter/d/a5b964/32.png) [@dashwood](https://discuss.elastic.co/u/dashwood)\
**Post date:** [March 21, 2017, 6:59am UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/7 "2017-03-21T06:59:08Z")

</div>

Is there a type that accepts both + and - ?

Also how would one reindex to a new index supposing my new index had the proper dynamic mapping

---

<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:** [March 21, 2017, 8:23am UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/8 "2017-03-21T08:23:29Z")

</div>

You can set it to keyword.

---

<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 18, 2017, 8:23am UTC](https://discuss.elastic.co/t/changing-dynamic-mapping/79189/9 "2017-04-18T08:23:34Z")

</div>

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