# Need help to reindex with date format changed

**URL:** https://discuss.elastic.co/t/need-help-to-reindex-with-date-format-changed/171980
**Category:** Elasticsearch
**Created:** [March 12, 2019, 2:36pm UTC](https://discuss.elastic.co/t/need-help-to-reindex-with-date-format-changed/171980 "2019-03-12T14:36:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![piet](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@piet](https://discuss.elastic.co/u/piet)
#### Post date: [March 12, 2019, 2:36pm UTC](https://discuss.elastic.co/t/need-help-to-reindex-with-date-format-changed/171980/1 "2019-03-12T14:36:00Z")

</div>

I try to re-index a index to a new one. Reason is i wan't to change the date format.  
But it throws error:

```
 "cause": {
    "type": "mapper_parsing_exception",
    "reason": "failed to parse [start_date]",
    "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "Invalid format: \"2019-01-30 13:03\" is too short"
    }
 },

```

My origin index field mapping for this looks like:

```
"start_date": {
  "type": "date",
  "format": "yyyy-MM-dd HH:mm",
   "fields": {
    "keyword": { 
      "type": "keyword"
    }
  }
}

```

and it should look:

```
"start_date": {
  "type": "date",
  "format": "yyyy-MM-dd HH:mm:ss",
   "fields": {
    "keyword": { 
      "type": "keyword"
    }
  }
}

```

But i cannot reindex it.  
What can i do?

---

<div class="post-metadata">

### Author: ![piet](https://avatars.discourse-cdn.com/v4/letter/p/a9adbd/32.png) [@piet](https://discuss.elastic.co/u/piet)
#### Post date: [March 12, 2019, 3:19pm UTC](https://discuss.elastic.co/t/need-help-to-reindex-with-date-format-changed/171980/2 "2019-03-12T15:19:23Z")

</div>

Found the solution:  
It needs just adding a script to reindex post:

```
"script": {
   "source": "ctx._source.start_date = ctx._source.start_date + ':00';"
 }

```

and it will work like a charme.

---

<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 9, 2019, 3:19pm UTC](https://discuss.elastic.co/t/need-help-to-reindex-with-date-format-changed/171980/3 "2019-04-09T15:19:24Z")

</div>

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