如何使用Bulk API将数据从一个Elasticsearch索引移动到另一个 [英] How to move data from one Elasticsearch index to another using the Bulk API

查看:578
本文介绍了如何使用Bulk API将数据从一个Elasticsearch索引移动到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

我建议使用 Logstash ,即您使用一个 弹性搜索输入插件来检索索引中的数据和另一个 elasticsearch 输出插件将数据推送到其他索引。



配置logstash配置文件将如下所示:

  {
elasticsearch {
hosts => localhost:9200
index => source_index< ---您的源索引名称
}
}
过滤器{
mutate {
remove_field => [@version,@timestamp]
}
}
输出{
elasticsearch {
host => localhost
port => 9200
协议=> http
manage_template => false
index => target_index< ----目标索引名称
document_type => your_doc_type< ----确保设置相应的类型
document_id => %{id}
workers => 5
}
}

安装Logstash ,您可以这样运行:

  bin / logstash -f logstash.conf 


I am new to Elasticsearch. How to move data from one Elasticsearch index to another using the Bulk API?

解决方案

I'd suggest using Logstash for this, i.e. you use one elasticsearch input plugin to retrieve the data from your index and another elasticsearch output plugin to push the data to your other index.

The config logstash config file would look like this:

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
 }
}

After installing Logstash, you can run it like this:

bin/logstash -f logstash.conf

这篇关于如何使用Bulk API将数据从一个Elasticsearch索引移动到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆