我想将数据范围从木板文件写到弹性搜索,我想从数据范围的dyanamaly中创建索引和类型。
我的数据框是
timestamp country data
2017-08-16 00:00:00 india xyz
2017-08-16 00:00:00 US xyz
我有以下代码将其写给ES
features.write.format("org.elasticsearch.spark.sql")
.mode(SaveMode.Append)
.option("es.resource","timestamp/country").save()
但这无法正常工作,我期望的
这将创建索引" timestamp
"和类型" country
"
但是,我想创建索引为" 2017-08-16 00:00:00
"和两种类型" india
"one_answers" US
"
尝试
import org.elasticsearch.spark.rdd.EsSpark
使用saveToEs
方法。有关详细信息,请参阅
val game = Map("type"->"game","title" -> "FF VI","year" -> "1994")
val book = Map("type" -> "book","title" -> "Harry Potter","year" -> "2010")
val cd = Map("type" -> "music","title" -> "Surfing With The Alien")
sc.makeRDD(Seq(game, book, cd)).saveToEs("index/{type}")