At first when I had to recreate or change an index in ElasticSearch I used a rather naïve approach. I deleted and recreated my index and start processing all data again from the original source.
This approach worked but put a lot of stress on the network and ElasticSearch nodes.
A better solution is to use the reindex API. It enables you to reindex your documents without requiring any plugin nor external tool.
Thanks to the existence of the _source
field you already have the whole document available to you in Elasticsearch itself. This means you can start from your existing index and use the reindex API to create a new index next to it:
POST _reindex { "source": { "index": "twitter" }, "dest": { "index": "new_twitter" } }
Remark: Reindex does not attempt to set up the destination index. You should set up the destination index prior to running a _reindex
action, including setting up mappings, shard counts, replicas, etc.
More information: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html