Reputation: 3515
i am using ElasticSearch node client to perform queries but i want to connect to different IP address then localhost, I want to achieve this
Client client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host1"), 9300))
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("host2"), 9300));
thing in node client
Node node = nodeBuilder().clusterName("yourcluster").client(true).node();
Client client = node.client();
please help me, I want to use Node Client
with other hosts not TransportClient
Upvotes: 0
Views: 1275
Reputation: 1256
Node client automatically discovers all the nodes of the cluster because it's actually a part of the cluster itself, you don't need to list the hosts manually. But if your cluster resides in another network which can't be discovered automatically you may also specify at least one cluster host with settings.
Settings.Builder settings = Settings.builder()
.put("path.home", ".")
.put("discovery.zen.ping.unicast.hosts","192.168.1.1");
Node node = NodeBuilder.nodeBuilder().settings(settings)
.clusterName("elasticsearch")
.client(true)
.node();
https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html
Upvotes: 1