Need help to reindex with date format changed

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?

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.

1 Like

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