Writing data from Spark to Elasticsearch

I am using spark2.0 and using the spark session variable .trying to write some data into elastic search cluster installed in my local machine.code snippet is given below

spark.conf.set("es.index.auto.create", "true")
spark.conf.set("es.nodes", "")
spark.conf.set("es.port", "9200")
val test = spark.createDataset(Seq(1,2))

Last line is throwing a compilation error .Can some one suggest what is the correct way of calling the saveToEs method?

You'll need to transform your Dataset to be compatible with the DataFrame type, which means it must have a schema, and be capable of being transformed into a Dataset of type [Row] to be consumed.

thank you James.
I was able to write using SaveToEs method . code is given below
val stats = spark.sql("select ... from table group by col1")

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.