0

I am trying to connect to a cluster on qbox the hosting service and I get an error relating to path. I am unsure how to specify the endpoint API. Has anyone any ideas?

public   Map<String, Object> putJsonDocument(int partid, String partnumber){
     Map<String, Object> jsonDocument = new HashMap<String, Object>();
     jsonDocument.put("partid", partid);
     jsonDocument.put("partnumber", partnumber);
     return jsonDocument;
}

public void ESUpdate() {

    org.elasticsearch.node.Node node = org.elasticsearch.node.NodeBuilder.nodeBuilder().node();
    Client client = node.client();
    client.prepareIndex("soogrindex", "searchrow", "1")
    .setSource(putJsonDocument(1, "test55" )).execute().actionGet();

  } 



Exception in thread "main" java.lang.IllegalStateException: path.home is not configured
at org.elasticsearch.env.Environment.<init>(Environment.java:101)
at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:81)
at org.elasticsearch.node.Node.<init>(Node.java:128)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)
at com.example.GetSoogrSitemap.ESUpdate(GetSoogrSitemap.java:708)
at com.example.GetSoogrSitemap.main(GetSoogrSitemap.java:2056)
Trevor Oakley
  • 438
  • 5
  • 17
  • org.elasticsearch.node.NodeBuilder.nodeBuilder() .settings(Settings.builder() .put("path.home", "https://...qb0x.com:30950") .node(); – Trevor Oakley Feb 12 '16 at 06:34

1 Answers1

1

Using NodeBuilder you can only connect to an Elasticsearch server running on the same host as your program. It seems you're trying to connect to a cluster on QBox from your laptop or another host not located on the same QBox host.

You should try building a TransportClient instead, like this:

Client client = TransportClient.builder().build()
        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("your.qbox.host"), 9300));
Val
  • 207,596
  • 13
  • 358
  • 360
  • Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor; at org.elasticsearch.threadpool.ThreadPool.(ThreadPool.java:190) at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:133) at com.example.GetSoogrSitemap.ESUpdate(GetSoogrSitemap.java:720) at com.example.GetSoogrSitemap.main(GetSoogrSitemap.java:2078) – Trevor Oakley Feb 12 '16 at 07:25
  • What version of ES are you using (server-side and client-side)? – Val Feb 12 '16 at 07:33
  • qbox - 2.1.1 and client 2.2.0 but I changed now the client to 2.1.1 and still the same error. I tried also using variations on TransportClient but same error. – Trevor Oakley Feb 12 '16 at 07:45
  • Interesting is that with the http some nonsense the same error, therefore the http not being found at all or not recognised, here is the full http - https://23ebed6f82b55e4b7cf1:f0680bcb86@3a7721e6.qb0x.com:30950 – Trevor Oakley Feb 12 '16 at 07:51
  • There seems to be a dependency conflict somewhere. Besides, you should not post links to your live cluster and even less with embedded credentials (just for your security). – Val Feb 12 '16 at 07:54
  • http://stackoverflow.com/questions/33544863/java-elasticsearch-client-always-null has the answer to the second error. Guava needs to be 18. I had 16. – Trevor Oakley Feb 12 '16 at 07:59
  • With live clusters they are just for test and I will delete them later anyway. – Trevor Oakley Feb 12 '16 at 08:00
  • Ok, glad you figured out the dependency issue. Works now? – Val Feb 12 '16 at 08:00
  • I have a new error which I need to resolve with qbox - says unknown host, so I have some config error somewhere. – Trevor Oakley Feb 12 '16 at 08:11
  • Make sure that your code looks like this: `new InetSocketTransportAddress(InetAddress.getByName("3a7721e6.qb0x.com"), 30950)`, i.e. use only the host name and no credentials and no port number in the host name. – Val Feb 12 '16 at 08:12
  • The system is not fully working but the original error is solved. I am waiting for qbox tech support to reply about the correct InetAddress. – Trevor Oakley Feb 12 '16 at 16:06