I’m using the Java API, but I keep getting this error:
org.elasticsearch.client.transport.NoNodeAvailableException: None of the
configured nodes are available:
Even if I run my code on the same machine as Elasticsearch I get
this error.
Any ideas why this is? I was able to make contact once, then it
stopped.
Here is my TransportClient implementation. I decided to place
the code on the server to be sure, still no good.
I’ve tried several implementations with the put method. With and
without cluster.name or network.host:
public class ClientTransport {
public Client client;
@SuppressWarnings("resource")
public ClientTransport(){
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "store_cluster").put("network.host","127.0.0.1").build();
this.client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("http://127.0.0.1", 9300));
}
}
Here is usage of the ClientTransport class:
public static void main(String[]
args){
Map<String, Object> json = new
HashMap<String, Object>();
json.put("user","kimchy");
json.put("postDate",new Date());
json.put("message","trying out Elasticsearch");
IndexResponse response = null;
ClientTransport c = new
ClientTransport();
for(int x = 0;x<10;x++){
response = c.client.prepareIndex("twitter2", "tweet").setSource(json).execute().actionGet();
System.out.println("Index: "+response.getIndex());
System.out.println("Type: "+response.getType());
System.out.println("Id: "+response.getId());
System.out.println("Is Created: "+response.isCreated());
}
//do I need to fluch data?
//client.admin().indices().flush(new
FlushRequest('location').refresh(true)).actionGet()
c.client.close();
}
Here is a simplified version of your code that works. Copy, compile and run it (you'll need to change the cluster name). Hopefully from this example your can figure out what is wrong with your original code.
public static void main(String args[]) {
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build();
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("127.0.0.1", 9300));
Map<String, Object> json = new HashMap<String, Object>();
json.put("user","kimchy");
json.put("postDate",new Date());
json.put("message","trying out Elasticsearch");
IndexResponse response = null;
for(int x = 0;x<10;x++){
response = client.prepareIndex("test", "tweet").setSource(json).execute().actionGet();
System.out.println("Index: "+response.getIndex());
System.out.println("Type: "+response.getType());
System.out.println("Id: "+response.getId());
System.out.println("Is Created: "+response.isCreated());
}
//do I need to fluch data?
//client.admin().indices().flush(new
//FlushRequest("location").refresh(true).actionGet();
client.close();
}
I went back to version 1.7.1 of ES and the same code worked out of the box. No issues. I have read this is a version issue with v 2 of ES. Is that the case, if so is there an issue open about this?
I have the similar issue, I am running both client and server using ES 2.1.2 version, this is interesting when I run Java client program on ES server it works fine, if move client to another server I get this exception.
Any solution
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.