我正在尝试使用resthighlevelclient创建索引,客户端已成功创建,但在创建索引时出现错误。
CreateIndexRequest request = new CreateIndexRequest(elasticsearchIndex);
request.settings(Settings.builder()
.put("index.number_of_shards", 1)
.put("index.number_of_replicas", 0)
);
org.elasticsearch.client.indices.CreateIndexResponse createIndexResponse = elasticsearchClient.indices().create(request, RequestOptions.DEFAULT);
Exception in thread "main" java.net.ConnectException: Connection refused
at org.elasticsearch.client.RestClient.extractAndWrapCause(RestClient.java:788)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:218)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:205)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1454)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1439)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1406)
at org.elasticsearch.client.IndicesClient.create(IndicesClient.java:128)
请告诉我根本原因或任何解决办法。
谢谢
1条答案
按热度按时间bwleehnv1#
您的应用程序似乎无法连接到elasticsearch服务器,是否可以检查jhlrc客户端配置(主机名和端口)中提供的连接设置,并确保已连接到elasticsearch。
你可以通过点击你的elasticsearch主机名和端口,使用rest客户端(如postman等)来检查连接。还要确保你的应用程序和elasticsearch服务器具有网络连接。