# How to update date field type to a string in ES?

**URL:** <https://discuss.elastic.co/t/how-to-update-date-field-type-to-a-string-in-es/296131>\
**Category:** Elasticsearch\
**Created:** [February 2, 2022, 10:25pm UTC](https://discuss.elastic.co/t/how-to-update-date-field-type-to-a-string-in-es/296131 "2022-02-02T22:25:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![srk1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srk1/32/88697_2.png) [@srk1](https://discuss.elastic.co/u/srk1)\
**Post date:** [February 2, 2022, 10:25pm UTC](https://discuss.elastic.co/t/how-to-update-date-field-type-to-a-string-in-es/296131/1 "2022-02-02T22:25:10Z")

</div>

Hi ES team,  
I am trying to build a custom ES template where one field would occasionally passes a string that matches with date format causing mapping conflicts and dropping of data by logstash. If i try to disable auto date detection for a field in advanced settings, the index is coming up fine but i couldn't search based on time in kibana as ES is treating timestamp field as a string.  
I would want something with auto date detection on and one field to be a string no matter what type of data is passed through it. Can you please let me know of potential solutions for this?

Thanks,  
SRK.

---

<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:** [February 2, 2022, 10:45pm UTC](https://discuss.elastic.co/t/how-to-update-date-field-type-to-a-string-in-es/296131/2 "2022-02-02T22:45:12Z")

</div>

This is usually what a template would handle for you.

Perhaps if you shared the one that you have we can help.

---

<div class="post-metadata">

**Author:** ![srk1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/srk1/32/88697_2.png) [@srk1](https://discuss.elastic.co/u/srk1)\
**Post date:** [February 2, 2022, 10:49pm UTC](https://discuss.elastic.co/t/how-to-update-date-field-type-to-a-string-in-es/296131/3 "2022-02-02T22:49:06Z")

</div>

I am using default template with auto date detection off. Are you saying that i need to add that particular field and explicitly mention to treat it as a string? if i do that, would the advanced settings override the earlier declared 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:** [February 2, 2022, 10:57pm UTC](https://discuss.elastic.co/t/how-to-update-date-field-type-to-a-string-in-es/296131/4 "2022-02-02T22:57:41Z")

</div>

> [@srk1](#):
>
> Are you saying that i need to add that particular field and explicitly mention to treat it as a string

Yes, you need to define your own template for the index.

> [@srk1](#):
>
> if i do that, would the advanced settings override the earlier declared mapping?

It'd only apply for new indices created.

---

<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:** [March 2, 2022, 10:57pm UTC](https://discuss.elastic.co/t/how-to-update-date-field-type-to-a-string-in-es/296131/5 "2022-03-02T22:57:57Z")

</div>

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