Rename a field of particular index


can we rename a field in particular field index, Please help me with an example

(David Pilato) #2

No you can't rename a field.
Field aliases are coming though.

But for now you probably have to reindex.


thanks for your help,
ok, i have 17 lakhs of documents which was loaded from sql database to elasticsearch. It almost took 10hours to load the 17 lakhs+ huge amount of data.

Please correct me if i am wrong @dadoonet ,
So to rename a particular field, do i need to again create new index , rename the field and load complete 17 lakhs+ huge amount of data again.

waiting for your response,


(Christian Dahlqvist) #5

You will indeed need to create a new index and index all the data into this, but you can use the reindex API together with a script or ingest pipeline to do this within Elasticsearch instead of reading it from the source.

If you are on a recent version and want to be able to search by a different field name but are happy to leave the source document as it is, you should as David suggested be able to add a field alias to your mapping.

(David Pilato) #6

Oh! I thought this feature was only in 7.0 :slight_smile:

Thanks @Christian_Dahlqvist :wink:

(Mark Walkom) #7

A post was split to a new topic: Index data from mongo to Elasticsearch


I got this problem solved by changing fieldname, by reindexing: field1->field2

POST _reindex
"source": {
"index": "accountindex"
"dest": {
"index": "accountindex_new"
"script": {
"inline": "ctx._source.field2 = ctx._source.remove("field1")"