Better Elasticsearch client to connect AWS Elasticsearch from JAVA Spring-boot

Viewed 1399

I am a new bee for Spring-boot. I need to query AWS Elasticsearch. The endpoint looks like below

https://vpc-xxxxxx.es.amazonaws.com

I'm not sure which is the better client to opt for, as there are multiple options. I checked spring-boot-starter-data-elasticsearch and org.elasticsearch.client. Looks like the clients are taking port of cluster nodes' (9300). Since I'm using AWS ES I don't have access to nodes' port. Here the port used is 443. Please suggest me the better ES client which supports AWS ES Service.

2 Answers

Since you are using port 9300, it indicates that you are trying connect TransportClient remotely to an Elasticsearch cluster

According to official ES doc,

Deprecated in 7.0.0. The TransportClient is deprecated in favour of the Java High Level REST Client and will be removed in Elasticsearch 8.0.

And even according to this blog, the high-level client will eventually replace the transport client in the future.

So, if you are developing a new application, its better to use Java High Level REST Client

Now, as you have got your endpoint, you can now communicate to Elasticsearch using the HTTP protocol.

You will be able to see cluster information

enter image description here

You can now easily create index, index data in it, delete index ,etc.

For eg. In the following images shown, I have created an index customer

enter image description here

enter image description here

enter image description here

  • To know more about how you can use Java High Level REST Client with Spring Boot to talk to AWS Elasticsearch, you can refer this article

You can also refer to this answer

The port 9300 indicates that you are trying to connect via transport. This is one way of connecting to elasticsearch which is deprecated from v7. You want to use the rest (http) client, which communicates via http calls. This is now the recommended way of communicating with elasticsearch. Transport used to be the recommended for performance reasons, but not anymore.

You did not mention your elastic version, but one option is to use the high level java rest client.

Related