Can't connect to ElasticSearch server using Java API

后端 未结 4 928
醉梦人生
醉梦人生 2020-12-29 05:22

I am trying to connect to an ElasticSearch server using the Java API. I using elasticsearch service to start/stop and elasticsearch head for visualising the cluster. The clu

4条回答
  •  情深已故
    2020-12-29 05:49

    In case anybody else stumbles on this thread, I found out another reason you could receive this error is because the cluster_name has been changed to something other than the default.

    To see your current cluser_name:

    curl -XGET localhost:9200/_cluster/nodes?pretty=true
    

    Use code similar to what OP has above:

    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", "test").build();
    Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
    

    Source: http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html

提交回复
热议问题