Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch copy the index from one server to another server?

How to copy ES (v 5.x) index from one server to another server. i don't have privileges to install any software in that machine. have any better solution to copy the index ? will backup and restore work? please share your suggestion

like image 511
Learn Hadoop Avatar asked Mar 08 '18 14:03

Learn Hadoop


People also ask

How do I copy Elasticsearch index?

Indices can only be cloned if they meet the following requirements: The target index must not exist. The source index must have the same number of primary shards as the target index. The node handling the clone process must have sufficient free disk space to accommodate a second copy of the existing index.

How do I export Elasticsearch index data?

Elasticsearch Export Methods Here are three popular methods, you use to export files from Elasticsearch to any desired warehouse or platform of your choice: Elasticsearch Export: Using Logstash-Input-Elasticsearch Plugin. Elasticsearch Export: Using Elasticsearch Dump. Elasticsearch Export: Using Python Pandas.

How do I populate an Elasticsearch index?

Create a document or Add data After creating an index, we can now index the document to elasticsearch. We will use the POST method for this and specify some IDs for documents to identify them. Set request method = POST. Here POST is request method and _doc is used for document type to add data in the index.


2 Answers

You can reindex from remote server

POST _reindex
{
  "source": {
    "remote": {
      "host": "http://otherhost:9200",
      "username": "user",
      "password": "pass"
    },
    "index": "source",
    "query": {
      "match": {
        "test": "data"
      }
    }
  },
  "dest": {
    "index": "dest"
  }
}

You can also use snapshots but it will require you to change config files and have storage accessible by both servers

like image 197
pkhlop Avatar answered Sep 21 '22 09:09

pkhlop


Reindex will copy your documents from the source index to the destination index. But before you do that your destination index needs to be created and configured first. Reindexing won't copy your settings and mappings from the old index to the new index. To get everything, you need to create a snapshot of the source index and then restore it in the destination index. Here is the elasticsearch documentation for snapshot and restore. This link is also pretty helpful.

like image 28
WaughWaugh Avatar answered Sep 23 '22 09:09

WaughWaugh