Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AviranAbady/bae5e429c63a5baf71814a2df649a018 to your computer and use it in GitHub Desktop.
Save AviranAbady/bae5e429c63a5baf71814a2df649a018 to your computer and use it in GitHub Desktop.
elasticsearch reindex nested date formats
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