我是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。