Trying to re-index an index because the format of date field changed. The format changed from
...
"start_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
...
to
...
"start_date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
...
I try to re-index my index into a tmp index but it throws the following 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"
}
},
So, now i have a big problem. How to change the format of my date field? Is there another option not to re-index?
Since the format changed, what you need to do is to append :00
to your date field in order to match the new format:
POST _reindex
{
"source": {
"index": "oldindex"
},
"dest": {
"index": "newindex"
},
"script": {
"source": "ctx._source.start_date = ctx._source.start_date + ':00';"
}
}