Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AviranAbady/53d1d8795163d4cd377b28e75564aee7 to your computer and use it in GitHub Desktop.
Save AviranAbady/53d1d8795163d4cd377b28e75564aee7 to your computer and use it in GitHub Desktop.
Elasticsearch reindex with inline script - casting of nested values
POST _reindex
{
"source": {
"index": "vehicles"
},
"dest": {
"index": "vehicels-back"
},
"script": {
"lang": "painless",
"inline": "def fuel_types = ctx._source.fuel_types; for(ft in fuel_types){if(ft.containsKey('tank_number')) {ft.tank_number = ft.tank_number.toString()}} ctx._source.fuel_types=fuel_types"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment