【问题标题】:How to move data from one Elasticsearch index to another using the Bulk API如何使用 Bulk API 将数据从一个 Elasticsearch 索引移动到另一个索引
【发布时间】:2015-10-29 10:54:04
【问题描述】:

我是 Elasticsearch 的新手。如何使用 Bulk API 将数据从一个 Elasticsearch 索引移动到另一个?

【问题讨论】:

  • 您好,请详细说明您的问题,让我们知道您到目前为止所做的尝试。这样我们就可以更了解情况以帮助您解决您的情况

标签: elasticsearch


【解决方案1】:

我建议为此使用Logstash,即您使用一个elasticsearch input 插件从您的索引中检索数据,并使用另一个elasticsearch output 插件将数据推送到您的另一个索引。

config logstash 配置文件如下所示:

input {
  elasticsearch {
   hosts => "localhost:9200"
   index => "source_index"           <--- the name of your source index
  }
}
filter {
 mutate {
  remove_field => [ "@version", "@timestamp" ]
 }
}
output {
 elasticsearch {
   host => "localhost"
   port => 9200
   protocol => "http"
   manage_template => false
   index => "target_index"           <---- the name of your target index
   document_type => "your_doc_type"  <---- make sure to set the appropriate type
   document_id => "%{id}"
   workers => 5
 }
}

installing Logstash之后,可以这样运行:

bin/logstash -f logstash.conf

【讨论】:

  • 感谢 Valentin 的重播,如果没有 logstash 并且在 Elasticsearch 中仅使用 Bulk API,这是否可行。
  • 是的,基本上是通过重新实现logstash 的功能:-) 有很多可用的示例,其中之一是here。如果您使用的是 Python,则可以使用 reindex helper
猜你喜欢
  • 2017-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-11
  • 2021-05-04
  • 2016-03-13
相关资源
最近更新 更多