繁体   English   中英

如何在Spark中使用Elasticsearch-Hadoop将数据从一个Elasticsearch集群重新索引到另一个集群

[英]How to reindex data from one Elasticsearch cluster to another with elasticsearch-hadoop in Spark

我有两个单独的Elasticsearch集群,我想将第一个集群中的数据重新索引到第二个集群,但是我发现我只能在SparkContext配置中设置一个Elasticsearch集群,例如:

var sparkConf : SparkConf = new SparkConf()
                     .setAppName("EsReIndex")
sparkConf.set("es.nodes", "node1.cluster1:9200")

那么,如何在同一应用程序内部的Spark中使用弹性搜索-hadoop在两个Elasticsearch集群之间移动数据?

您无需为此配置SparkConf内部的节点地址。

当您使用DataFrameWriter与elasticsearch格式,你可以遵循通过该节点的地址作为一个选项:

val df = sqlContext.read
                  .format("elasticsearch")
                  .option("es.nodes", "node1.cluster1:9200")
                  .load("your_index/your_type")

df.write
    .option("es.nodes", "node2.cluster2:9200")
    .save("your_new_index/your_new_type")

这应该与spark 1.6.X和相应的elasticsearch-hadoop连接器一起使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM