[英]Exception in thread “main” org.elasticsearch.client.transport.NoNodeAvailableException: No node available
I am trying index using below Java code in elastic search.. I gave my machine Ip in the code .It is unable to connect to node. 我正在尝试使用下面的Java代码在弹性搜索中进行索引。我在代码中给了我的机器Ip。它无法连接到节点。 It is giving error like below :
它给出如下错误:
Exception in thread "main" org.elasticsearch.client.transport.NoNodeAvailableException: No node available at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:219) at org.elasticsearch.client.transport.support.InternalTransportClient.execute(InternalTransportClient.java:106) at org.elasticsearch.client.support.AbstractClient.index(AbstractClient.java:82) at org.elasticsearch.client.transport.TransportClient.index(TransportClient.java:330) at org.elasticsearch.action.index.IndexRequestBuilder.doExecute(IndexRequestBuilder.java:314) at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85) at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59) at test.test1.main(test1.java:30) 线程“主”中的异常org.elasticsearch.client.transport.NoNodeAvailableException: org.elasticsearch.client.transport.support.InternalTransportClient上的org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:219)上没有可用的节点 org上的org.elasticsearch.client.support.AbstractClient.index(AbstractClient.java:82)的.execute(InternalTransportClient.java:106)org的org.elasticsearch.client.transport.TransportClient.index(TransportClient.java:330)的。 org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)上org.elasticsearch.action.Action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)上的elasticsearch.action.index.IndexRequestBuilder.doExecute(IndexRequestBuilder.java:314)在test.test1.main(test1.java:30)
Code I am using: 我正在使用的代码:
public static void main(String[] args) {
String json = "{" +
"\"user\":\"AMaresh\"," +
"\"postDate\":\"2014-04-23\"," +
"\"message\":\"trying out Elasticsearch\"" +
"}";
Settings settings = ImmutableSettings.settingsBuilder().put("elasticsearch", "elasticsearch").build();
TransportClient transportClient = new TransportClient(settings);
Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("10.210.51.207",9300));
IndexResponse response = client.prepareIndex("Cricket", "cric", "1").setSource(json).execute().actionGet();
//List<String> matches = response.matches();
System.out.println(response);
System.out.println("finished");
I have checked ports are open in the machine. 我检查了机器中的端口是否打开。
Can anybody help me understanding the problem. 谁能帮助我理解问题。
Thanks in advance 提前致谢
I think the problem in mentioning cluster name.. Use lik following 我认为在提及集群名称时出现问题。
Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch").build();
Hope it helps..! 希望能帮助到你..!
This answer https://stackoverflow.com/a/25053586/3827220 to a similar problem, is applicable to the error message you're seeing. 这个答案https://stackoverflow.com/a/25053586/3827220针对类似的问题,适用于您所看到的错误消息。
Check to make sure you are using the same major version on the client side and the cluster side. 检查以确保您在客户端和群集侧使用的是相同的主版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.