in this guide:
https://www.elastic.co/guide/en/elasticsearch/hadoop/current/spark.html
it recommend user to use es 6.x version which not support multi type, but still guide user to set multi-type in one index
val game = Map("media_type"->"game","title" -> "FF VI","year" -> "1994")
val book = Map("media_type" -> "book","title" -> "Harry Potter","year" -> "2010")
val cd = Map("media_type" -> "music","title" -> "Surfing With The Alien")
sc.makeRDD(Seq(game, book, cd)).saveToEs("my-collection/{media_type}")
of cause, above code will fail:
rg.apache.spark.util.TaskCompletionListenerException: Found unrecoverable error [127.0.0.1:9200] returned Bad Request(400) - Rejecting mapping update to [my-collection] as the final mapping would have more than 1 type: [game, book]; Bailing out..
at org.apache.spark.TaskContextImpl.invokeListeners(TaskContextImpl.scala:138)
at org.apache.spark.TaskContextImpl.markTaskCompleted(TaskContextImpl.scala:116)
at org.apache.spark.scheduler.Task.run(Task.scala:124)