# Change the type in index from String to Date

**URL:** https://discuss.elastic.co/t/change-the-type-in-index-from-string-to-date/176426
**Category:** Elasticsearch
**Created:** [April 11, 2019, 2:45pm UTC](https://discuss.elastic.co/t/change-the-type-in-index-from-string-to-date/176426 "2019-04-11T14:45:42Z")
**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 11, 2019, 2:45pm UTC](https://discuss.elastic.co/t/change-the-type-in-index-from-string-to-date/176426/1 "2019-04-11T14:45:42Z")

</div>

Hello,  
I parsed a date from the log but it's type in the index was String. **I would like to change it to Date** so that i could display lines in kibana in the same order of the log file.  
Any suggestions will be apperciated.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 11, 2019, 3:18pm UTC](https://discuss.elastic.co/t/change-the-type-in-index-from-string-to-date/176426/2 "2019-04-11T15:18:24Z")

</div>

Change the mapping and use date instead of text.

---

<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 11, 2019, 3:22pm UTC](https://discuss.elastic.co/t/change-the-type-in-index-from-string-to-date/176426/3 "2019-04-11T15:22:28Z")

</div>

hi @dadoonet thanks for the quick reply. i'm a beginner, what i did is that i applied a grok filter

```
%{SYSLOGTIMESTAMP:Date}%{SPACE} 

```

How could i exactly change the mapping please. thanks

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 11, 2019, 3:41pm UTC](https://discuss.elastic.co/t/change-the-type-in-index-from-string-to-date/176426/4 "2019-04-11T15:41:28Z")

</div>

That does not change elasticsearch mapping. It just indicates how to extract a `SYSLOGTIMESTAMP` regular expression and put the extracted value in `Date` field.

You need to create the appropriate mapping for the `Date` field. See:

- [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)

---

<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 9, 2019, 3:41pm UTC](https://discuss.elastic.co/t/change-the-type-in-index-from-string-to-date/176426/5 "2019-05-09T15:41:34Z")

</div>

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