Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
Cover image for Migrate ElasticSearch Data Index to new Cluster
Manuel Montero
Manuel Montero

Posted on • Updated on

Migrate ElasticSearch Data Index to new Cluster

If you want to migrate on of your Elasticsearch Index to a new Cluster is very simple you just need to follow these couple of steps (If you are using ElasticSearch 5x or above):

Step 1:

Edit your elasticsearch.yml file of the new Cluster and add the following line changing REMOTE_HOST_OLD_CLUSTER and PORT with the one you use to connect to your old cluster:

reindex.remote.whitelist: [REMOTE_HOST_OLD_CLUSTER:PORT]

Step 2:

Send a Post request to your new cluster with the following template:

POST _reindex
{
  "source": {
    "remote": {
      "host": "https://REMOTE_ELASTICSEARCH_ENDPOINT:PORT",
      "username": "USER",
      "password": "PASSWORD"
    },
    "index": "INDEX_NAME",
    "query": {
      "match_all": {}
    }
  },
  "dest": {
    "index": "INDEX_NAME"
  }
}
Enter fullscreen mode Exit fullscreen mode

Need to update host, username and password with your old cluster.

And that's all! Need to wait some time if your index contains a lot of information.

You can migrate to another self hosted ElasticSearch or to cloud base like https://www.elastic.co/

Note:

If you are migration from one old version to a new version of Elasticsearch you can have problems with data types as they have change.

In case of issues what you can do is to first create the index on the new cluster with the correct data types and transfer your information the same as describe above.

Discussion (0)