I am developing a Spring Boot program that use RestHighLevelClient to insert document into ElasticSearch. Now I have built the configuration for the client, however, I am not sure how to insert/index. The documentation on ElasticSearch seems confusing to me..
Here is the piece of code I tried so far:
@KafkaListener(topics = "${kafka.topic}",groupId = "test")
public void receive(String message) {
LOGGER.info(message);
insertData(message);
latch.countDown();
}
private void insertData(String message){
IndexRequest request = new IndexRequest(
"fx-rate",
"_doc",
"1");
request.source(message, XContentType.JSON);
}