I want to ask that, how to change field names in elasticsearch index. I mean,
"_source": {
"name_of_field": "lorem"
}
change "name_of_field" to "new_name"
As mentioned by @Elasticsearch Ninja you can use the alias, you can also use update by query API
Adding a working example
Index Mapping:
{
"mappings": {
"properties": {
"name": {
"type": "text"
}
}
}
}
Index Data:
{
"name":"John"
}
Update by Query API
POST /_update_by_query
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "title"
}
}
}
},
"script" : {
"inline": "ctx._source.title = ctx._source.name; ctx._source.remove("name");"
}
}
By the above query name
field name will be changed to title