ElasticSearch connector based flink sql
With elasticsearch connector, you can use the Flink SQL to write data into ElasticSearch.
Let us have a brief example to show how to use the connector.
Please refer to the Elastic Doc to prepare elastic environment.
ElasticSearch provide different connectors for different version:
Here is a simple example of seatunnel configuration.
SET table.dml-sync = true; CREATE TABLE events ( id INT, name STRING ) WITH ( 'connector' = 'datagen' ); CREATE TABLE es_sink ( id INT, name STRING ) WITH ( 'connector' = 'elasticsearch-7', -- or 'elasticsearch-6' 'hosts' = 'http://localhost:9200', 'index' = 'users' ); INSERT INTO es_sink SELECT * FROM events;
Execute the following command in seatunnel home path to start the Flink SQL job.
$ bin/start-seatunnel-sql.sh -c config/elasticsearch.sql.conf
Verify result from elasticsearch.