【问题标题】:How to reindex data from one Elasticsearch cluster to another with elasticsearch-hadoop in Spark如何在 Spark 中使用 elasticsearch-hadoop 将数据从一个 Elasticsearch 集群重新索引到另一个集群
【发布时间】:2016-11-02 17:49:08
【问题描述】:

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

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

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

【问题讨论】:

    标签: scala elasticsearch apache-spark apache-spark-sql elasticsearch-hadoop


    【解决方案1】:

    您不需要为此在 SparkConf 中配置节点地址。

    当您使用 elasticsearch 格式的 DataFrameWriter 时,您可以将节点地址作为选项传递,如下所示:

    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 连接器。

    【讨论】:

      猜你喜欢
      • 2021-11-01
      • 2013-07-26
      • 2020-06-15
      • 2022-07-11
      • 1970-01-01
      • 2014-06-26
      • 2018-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多