更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

huangapple go评论113阅读模式
英文:

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

问题

我是Spring-boot的新手。我需要查询AWS Elasticsearch。端点如下所示:

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

我不确定应该选择哪个更好的客户端,因为有多个选项。我查看了spring-boot-starter-data-elasticsearchorg.elasticsearch.client。看起来这些客户端正在使用集群节点的端口(9300)。由于我在使用AWS ES,我没有访问节点的端口。在这里,使用的端口是443。请为我提供一个更好的支持AWS ES服务的ES客户端。

英文:

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.

答案1

得分: 2

由于您正在使用9300端口,这表示您正在尝试远程连接TransportClient到Elasticsearch集群。

根据官方的ES文档

> 在7.0.0中已弃用。TransportClient已被Java高级REST客户端取代,将在Elasticsearch 8.0中删除。

甚至根据这篇博客,高级客户端将在未来逐步取代传输客户端。

因此,如果您正在开发新应用程序,最好使用Java高级REST客户端

现在,您已经获得了终端节点,您现在可以使用HTTP协议与Elasticsearch通信。

您将能够查看集群信息

更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

您现在可以轻松地创建索引、在索引中索引数据、删除索引等。

例如,在下面显示的图像中,我创建了一个名为customer的索引

更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

  • 要了解更多关于如何使用Java高级REST客户端与Spring Boot通信到AWS Elasticsearch的信息,您可以参考这篇文章

您还可以参考这个答案

英文:

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

更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

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

更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

更好的Elasticsearch客户端,用于从JAVA Spring Boot连接到AWS Elasticsearch。

  • 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

答案2

得分: 1

端口9300表示您正在尝试通过传输进行连接。这是连接到Elasticsearch的一种方式,但自Elasticsearch v7起已不推荐使用。您应该使用REST(HTTP)客户端,该客户端通过HTTP调用进行通信。
这是目前推荐的与Elasticsearch通信的方式。出于性能原因,过去建议使用传输方式,但现在不再推荐使用。

您没有提及您使用的Elasticsearch版本,但一个选项是使用高级Java REST客户端

英文:

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.

huangapple
  • 本文由 发表于 2020年4月3日 21:35:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/61013136.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定