# Change a type in the index

**URL:** <https://discuss.elastic.co/t/change-a-type-in-the-index/176634>\
**Category:** Elasticsearch\
**Created:** [April 12, 2019, 1:44pm UTC](https://discuss.elastic.co/t/change-a-type-in-the-index/176634 "2019-04-12T13:44:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![WarriorHarb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warriorharb/32/43201_2.png) [@WarriorHarb](https://discuss.elastic.co/u/WarriorHarb)\
**Post date:** [April 12, 2019, 1:44pm UTC](https://discuss.elastic.co/t/change-a-type-in-the-index/176634/1 "2019-04-12T13:44:18Z")

</div>

Hello,  
I'm a beginner at ElasticSearch. I'm having a big confusion.  
I have got log lines, i parsed them via grok filter. the Date type in index was string.  
I asked how to chage it to date. i was told to reindex it. i read the documentations below:

- [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html)
- [https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html)

I didn't get how exactly to manipulate the mapping ? shall i map every field and then parse logs via logstash's filter grok or what ?

---

<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:** [April 12, 2019, 5:45pm UTC](https://discuss.elastic.co/t/change-a-type-in-the-index/176634/2 "2019-04-12T17:45:30Z")

</div>

The idea here is not to change the mapping of an existing index (as this is not possible like changing a string to a date), but create a new index fix a fixed mapping and then use the [reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/docs-reindex.html) to reindex the existing content into that new index with the new mapping being applied.

Hope this makes more sense.

---

<div class="post-metadata">

**Author:** ![WarriorHarb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warriorharb/32/43201_2.png) [@WarriorHarb](https://discuss.elastic.co/u/WarriorHarb)\
**Post date:** [April 15, 2019, 10:03am UTC](https://discuss.elastic.co/t/change-a-type-in-the-index/176634/3 "2019-04-15T10:03:24Z")

</div>

thanks @spinscale for your response.  
I know how to create a new index, but how exactly could i set its mapping to make the date a "DATE" type and not a "STARING"?

---

<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:** [April 15, 2019, 7:13pm UTC](https://discuss.elastic.co/t/change-a-type-in-the-index/176634/4 "2019-04-15T19:13:08Z")

</div>

See [https://www.elastic.co/guide/en/elasticsearch/reference/7.0/date.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/date.html)

---

<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:** [May 13, 2019, 7:13pm UTC](https://discuss.elastic.co/t/change-a-type-in-the-index/176634/5 "2019-05-13T19:13:09Z")

</div>

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