can we rename a field in particular field index, Please help me with an example
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,
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.
I got this problem solved by changing fieldname, by reindexing: field1->field2
"inline": "ctx._source.field2 = ctx._source.remove("field1")"