I think this can be done without re-indexing by adding the "ignore_malformed" flag to the mapping for the field. Here's what I tried and it worked:
Create new index with a "date" field
POST events
{
"mappings" : {
"dates" : {
"properties" : {
"lenient_date" : {
"type" : "date"
}
}
}
}
}
Try adding an malformed date value
PUT events/dates/1
{
"lenient_date" : "1/32/2014"
}
Result: parsing error (as expected)
{
"error": "MapperParsingException[failed to parse [lenient_date]]; nested: MapperParsingException[failed to parse date field [1/32/2014], tried both date format [dateOptionalTime], and timestamp number with locale []]; nested: IllegalArgumentException[Invalid format: \"1/32/2014\" is malformed at \"/32/2014\"]; ",
"status": 400
}
GET events/dates/1
Result: date not found (as expected)
{
"_index": "events",
"_type": "dates",
"_id": "1",
"found": false
}
Change mapping to allow malformed values
PUT events/dates/_mapping
{
"dates" : {
"properties" : {
"lenient_date" : {
"type" : "date",
"ignore_malformed" : true
}
}
}
}
Try adding the same bad date
PUT events/dates/1
{
"lenient_date" : "1/32/2014"
}
GET events/dates/1
Result: now works
{
"_index": "events",
"_type": "dates",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"lenient_date": "1/32/2014"
}
}
Note:
I'm running ES version 1.3.2. I have not checked how the updated mapping affects sorting and filtering.