Home Structured Streaming with ElasticSearch
Post
Cancel

Structured Streaming with ElasticSearch

Maven依赖

1
2
3
4
5
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch-spark-20_2.11</artifactId>
    <version>6.2.4</version>
</dependency>

writeStream

1
2
3
4
5
6
7
8
9
10
11
12
  .writeStream
  .outputMode(OutputMode.Append())//append only
 // .format("es") classNotFound es.DefaultSource
  .format("org.elasticsearch.spark.sql")
  .option("es.nodes", "localhost")
  .option("es.port", "9200")
  .option("checkpointLocation", "/tmp/checkpointLocation")
 // .option("es.mapping.id", "id")//if no mapping.id ?
  .trigger(Trigger.ProcessingTime(10, TimeUnit.SECONDS))
  .start("a/profile")
  .awaitTermination()
  
This post is licensed under CC BY 4.0 by the author.