Last active
July 18, 2018 17:26
-
-
Save jspooner/54cff2a299c4d1a3293f9d4c05c9bb8e to your computer and use it in GitHub Desktop.
Databricks + es-hadoop + Amazon Elasticsearch Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.elasticsearch.spark._ | |
import org.elasticsearch.spark.rdd.EsSpark | |
import org.elasticsearch.spark.sql._ | |
// Create a DataFrame to write to ElasticSearch | |
case class SimpsonCharacter(name: String, actor: String, episodeDebut: String) | |
val simpsonsDF = sc.parallelize( | |
SimpsonCharacter("Homer", "Dan Castellaneta", "Good Night") :: | |
SimpsonCharacter("Marge", "Julie Kavner", "Good Night") :: | |
SimpsonCharacter("Bart", "Nancy Cartwright", "Good Night") :: | |
SimpsonCharacter("Lisa", "Yeardley Smith", "Good Night") :: | |
SimpsonCharacter("Maggie", "Liz Georges and more", "Good Night") :: | |
SimpsonCharacter("Sideshow Bob", "Kelsey Grammer", "The Telltale Head") :: | |
Nil).toDF().repartition(1) | |
var esConfig:Map[String,String] = Map("es.nodes" -> "http://myescluster.us-east-1.es.amazonaws.com", | |
"es.port" -> "80", | |
"es.nodes.discovery" -> "false", | |
"es.nodes.wan.only" -> "true" | |
) | |
EsSparkSQL.saveToEs(simpsonsDF, "shows/simpsons", esConfig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
es-hadoop: elasticsearch-spark_2.10-2.2.0.jar
Spark: 1.6.1 (Hadoop1)
https://community.cloud.databricks.com/?o=1092363641874062#externalnotebook/https%3A%2F%2Fdocs.cloud.databricks.com%2Fdocs%2Flatest%2Fdatabricks_guide%2Findex.html%2303%2520Accessing%2520Data%2F4%2520Databases%2520%2526%2520DataSources%2F5%2520ElasticSearch.html