Created
April 13, 2021 19:24
-
-
Save AviranAbady/bae5e429c63a5baf71814a2df649a018 to your computer and use it in GitHub Desktop.
elasticsearch reindex nested date formats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT _ingest/pipeline/route_restriction_date_converter | |
{ | |
"description": "Convert dates to ISO format", | |
"processors": [ | |
{ | |
"date": { | |
"field": "start_date", | |
"target_field": "start_date", | |
"formats": [ | |
"strict_date_optional_time || MM/dd/yyyy || MM/dd/yyyy HH:mm" | |
] | |
} | |
}, | |
{ | |
"date": { | |
"field": "end_date", | |
"target_field": "end_date", | |
"formats": [ | |
"strict_date_optional_time || MM/dd/yyyy || MM/dd/yyyy HH:mm || epoch_millis" | |
] | |
} | |
}, | |
{ | |
"foreach": { | |
"ignore_missing": true, | |
"field": "route_restrictions", | |
"processor": { | |
"date": { | |
"field": "_ingest._value.end_date", | |
"target_field": "_ingest._value.end_date", | |
"formats": [ | |
"strict_date_optional_time || MM/dd/yyyy || MM/dd/yyyy HH:mm || epoch_millis" | |
] | |
} | |
} | |
} | |
}, | |
{ | |
"foreach": { | |
"ignore_missing": true, | |
"field": "route_restrictions", | |
"processor": { | |
"date": { | |
"field": "_ingest._value.start_date", | |
"target_field": "_ingest._value.start_date", | |
"formats": [ | |
"strict_date_optional_time || MM/dd/yyyy || MM/dd/yyyy HH:mm || epoch_millis" | |
] | |
} | |
} | |
} | |
} | |
] | |
} | |
POST _reindex | |
{ | |
"source": { | |
"index": "route_policy" | |
}, | |
"dest": { | |
"index": "route_policy_back", | |
"pipeline": "route_restriction_date_converter" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment