How To export selected type elasticsearch from server A to server B


(雪中的凤凰) #1

Hi Team,

my version elasticsearch is 2.40.
how to export selected type and fields data from elasticsearch server A to elastic server B.
Version elasticsearch server A and server B also 2.40.

Thanks and best regards
Sharon


(Luiz Santos) #2

Hi Sharon,

In early versions of elasticsearch you could use reindex from remote, but it is not available in version 2.4.0.

So you will need to define your own strategy to export this data. One of my favorites is to use logstash and define an input from source elasticsearch and an output to target elasticsearch.

Config file would be something like this:

input {
  # Read all documents from Elasticsearch matching the given query
  elasticsearch {
    hosts => "address_source_elasticsearch"
    query => '{ "query": { "match": { "statuscode": 200 } }, "sort": [ "_doc" ] }'
  }
}

output {
  elasticsearch {
    hosts => "address_target_elasticsearch"
  }
}

You can always create a script to do this work in your favorite language too.

Hope it helps.

Cheers,
LG


(Shane Connelly) #3

Just as a little text correction:

Should read

In later versions of elasticsearch you could use reindex from remote, but it is not available in version 2.4.0.

Reindex from remote was added in 5.0 of Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/5.0/docs-reindex.html#reindex-from-remote, so if "server B" is or can be version 5.x, then you could use this. I would encourage you to consider upgrading to 5.x or 6.x whenever possible regardless of this particular technical hurdle because of ongoing performance, functionality, and security improvements.

Anyway, presuming 5.x or 6.x is not an option in your case, @luiz.santos's solution is a good one!


(Luiz Santos) #4

Thank you for the correction @shanec :slight_smile:


(system) #5

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