Great job regarding support for Spark 2.2.0 structured streaming!! I tried it and it works well.
However, I wonder why you limited the sink to work only in APPEND mode. If user provides es.mapping.id column, you can support UPDATE mode easily (actually, with no code change at all). When information for a certain window of time arrives, the sink will write the data to elasticsearch using the ID. When an update arrives for the same ID, elasticsearch will overwrite that document, since the same ID was used.
Adding the ability to work in UPDATE mode will make elasticsearch a great selection for a sink in our project.
BTW, when is it plan to make elasticsearch-hadoop 6.0.0 a GA version?
Thanks for trying out the new structured streaming feature and for your feedback on it! We agree on the UPDATE mode sentiments and have plans to eventually support it in a later release. We wanted to make sure that we were supporting what we felt was the most common use case in the first iteration. Keep an eye open though!
I am trying to use ES Sink for Structured streaming but did not find any working example. I tried using the example https://www.elastic.co/guide/en/elasticsearch/hadoop/current/spark.html#spark-sql-streaming in a test application with socket as source and it seems to hang. If you've been able to use it, can you please share an sample/documentation on it's usage ?
It works really well for me. Several considerations:
End the program with
query.awaitTermination();
Configure checkpoint location.
Output mode must be append.
In SparkSession you must configure elasticsearch details.
In groupBy datasets you must configure watermark.
The start method on the query should contain the index name and doc type.
Maybe your logging definition is not set correctly so you cannot see Spark's errors? All the configurations above create exceptions if not set correctly.
Spark 2.2.0 is required.
Here is my full java code for handling CSV files. I have other program that create those files every 10 seconds and add them to the input dir. I ran it both on my local machine and in spark cluster (had to remove the master declaration from SparkSession to let spark-submit.sh define it).
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.