Hi, I've looked all over for how to rename a field and everyone mentions doing a reindex. But isn't a script just as if not more effective (if you don't want to reindex). I just want to make sure I'm not missing something vital here because this seems like a perfectly good solution!
POST /indexName/_update_by_query
{
"script": {
"source":"ctx._source.newField =ctx._source.oldField"
},
"query": { "match_all":{} }
}
POST /indexName/_update_by_query
{
"script": {
"inline": "ctx._source.remove(\"oldField\")"
},
"query": { "match_all":{} }
}
Or even
POST /indexName/_update_by_query
{
"script": {
"source":"ctx._source.newField =ctx._source.remove(\"oldField\")"
},
"query": { "match_all":{} }
}