asticsearch 2.4 java 1.7 ошибка соединения NoNodeAvailableException
Я хочу создать соединение с asticsearch для того, чтобы выполнить запрос
это мое исключение, дек. 28, 2017 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
Спасибо за помощь
1 ответ
Неверная инициализация транспортного клиента es:
Вот простой пример инициализации:
Settings settings = Settings.builder()
.put("cluster.name", "myClusterName").build();
TransportClient client = new PreBuiltTransportClient(settings).addTransportAddress(new TransportAddress(InetAddress.getByName("host1"), 9300))
.addTransportAddress(new TransportAddress(InetAddress.getByName("host2"), 9300));
больше обратитесь к ссылке