2

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.

rmn.nish
  • 871
  • 2
  • 8
  • 24

2 Answers2

2

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

ESCoder
  • 15,431
  • 2
  • 19
  • 42
  • @rmn.nish did you get a chance to go through my answer, looking forward to get feedback from you and if it's helpful, please dont forget to upvote and accept :) – – ESCoder May 12 '20 at 06:00
  • how you authorize/authenticate your request in AWS elasticsearch instance? In the blog it shows without any authorization, any idea how to implement that? – Roul Jun 13 '21 at 11:58
1

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.

Alkis Kalogeris
  • 17,044
  • 15
  • 59
  • 113