【发布时间】:2018-06-08 21:13:42
【问题描述】:
我想与 elasticsearch 建立连接以执行查询
这是我的例外 déc。 2017 年 2 月 28 日上午 10:06:11
org.elasticsearch.plugins.PluginsService <init>
INFOS: [Shockwave] modules [], plugins [], sites []
Exception in thread "main" NoNodeAvailableException[None of the configured nodes are available: []]
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:290)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:207)
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:288)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:64)
at com.intelcom.boot.App.<init>(App.java:59)
at com.intelcom.boot.App.main(App.java:71)
这是我的主要代码
TransportClient client ;
InetSocketTransportAddress node = new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300);
Settings settings = Settings.builder().put("cluster.name", "elasticsearch").put("client.transport.sniff", true)
.build();
client = TransportClient.builder().settings(settings).build();
SearchRequestBuilder builder = client.prepareSearch("index")
.setTypes("index_type")
.setQuery(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("_all", "Rabat")));
System.out.println(builder);
SearchResponse response = builder.get(); //<<<==== error
感谢您的帮助
【问题讨论】:
-
从未使用过节点......
-
如何添加?? (非常感谢你)