gpt4 book ai didi

java - ElasticSearch TransportClient 版本 5.6

转载 作者:行者123 更新时间:2023-12-02 12:03:24 27 4
gpt4 key购买 nike

我是 Elastisearch Java API 新手

我安装了版本5.6,我的服务器elasticsearch正在运行

http://localhost:9200/

 {
"name" : "KJj0iv3",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "0je2mMloQ52X_GT1itxGuA",
"version" : {
"number" : "5.6.3",
"build_hash" : "1a2f265",
"build_date" : "2017-10-06T20:33:39.012Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}

这是我的测试 Java 课

public static void main(String[] args) throws UnknownHostException {
try {
TransportClient client;

client = new PreBuiltTransportClient(Settings.EMPTY)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9200));
// on shutdown
client.close();
} catch (ElasticsearchException e) {
System.out.println(e.getMessage());
}
}

这是我的错误

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.logging.log4j.Logger.debug(Ljava/lang/String;Ljava/lang/Object;)V
at org.elasticsearch.threadpool.ThreadPool.<init>(ThreadPool.java:203)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:129)
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:265)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:130)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:116)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:106)
at queryDsl.Test.main(Test.java:24)

最佳答案

在 9200 上使用端口 9300 代替 TransportClient需要端口 9300,因为它使用传输模块进行通信。

关于java - ElasticSearch TransportClient 版本 5.6,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47078492/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com