Sink that indexes documents into Elasticsearch.
This Elasticsearch sink only supports indexing JSON documents.
It consumes data from an input destination and then indexes it to Elasticsearch.
The input data can be a plain json string, or a java.util.Map
that represents the JSON.
It also accepts the data as the Elasticsearch provided XContentBuilder
.
However, this is a rare case as it is not likely the middleware keeps the records as XContentBuilder
.
This is provided mainly for direct invocation of the consumer.
The Elasticsearch sink has the following options:
-
From the folder
elasticsearch-sink
:./mvnw clean package
-
cd apps
-
cd to the proper binder generated app (Kafka or RabbitMQ)
-
./mvnw clean package
-
Make sure that you have Elasticsearch running. For example you can run it as a docker container using the following command.
docker run -d --name es762 -p 9200:9200 -e "discovery.type=single-node" elasticsearch:7.6.2
-
Start the middleware (Kafka or RabbitMQ) if it is not already running.
-
java -jar target/elasticsearch-sink-<kafka|rabbit>-3.0.0-SNAPSHOT.jar --spring.cloud.stream.bindings.input.destination=els-in --elasticsearch.consumer.index=testing
-
Send some JSON data into the middleware destination. For e.g:
{"foo":"bar"}
-
Verify that the data is indexed:
curl localhost:9200/testing/_search