How to rename field name in Elasticsearch with Time efficient?

I have been using the following query to rename fieldName.

POST http://localhost:9200/INDEX_NAME/_update_by_query
	"query": { 
		"exists": {
            "field": "NEW_FIELD_NAME"
	"script" : {
		"inline": "ctx._source.NEW_FIELD_NAME = ctx._source.OLD_FIELD_NAME; ctx._source.remove(\"OLD_FIELD_NAME\");"

But for more than 42 Lakhs of data. It takes about 2-3 minutes.

Is there any way to reduce timing?....
The Elasticsearch version is 5.6.4


We have release 8.1.0 so you are far behind the supported versions.
With the recent version, you could use field aliases which has an immediate effect but the old field still exists.

If you really want to remove, there is no other way than reindexing.
I'd recommend to do a reindex from remote and reindex your whole data from 5.6 to 8.1 and using an ingest pipeline using the rename-processor.

It will take a significant amount of time anyway.


try slice and scroll_size params

I'm unsure if "slice" was implemented by then. :wink:

The doc has slice,means it can work?

Ha! Good. I didn't check. This version is so old! :wink:

Yep, 5.X has been EOL for years now and is no longer supported.
Please upgrade as a matter of urgency.

Thanks for the time. I think upgrading the version will take so much time in my company. So I will keep it in hold for now.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.