How to setup the ES cluster using the Client APIs


Somehow the default multicast discovery is not working for me and I am
exploring the unicast discovery mechanism to set up a ES cluster on two
physical machines. I am am able to set up it using the default ES
installation on two machines with configuring the both YML files to point
to each other using UNICAST discovery. Now, I want to achieve the same
thing using the ES Client API and I am using the below code for it. Could
you let me know if below code is correct to point to two nodes in UNICAST
or kindly point me to the right direction to refer the sample client code
for it. I am facing issue in the below code and unicast discovery is also
not working in below code.
(I have around one week experience on ES and want to migrate one of the
product from lucene to ES).

Settings settings1 = ImmutableSettings.settingsBuilder()
.put("", "PBcluster")
.put("node.master", true)
.put("", true)
//.put("http.port", 9250)
//.put("network.bind_host", "")
// .put("network.publish_host", "")
.put("", false)
// .put("", "["",
.put("", "")
.put("discovery.zen.minimum_master_nodes", 1)

node1 = nodeBuilder().settings(settings1).node();
System.out.println("Starting node1...");
System.out.println("Started node1...");
Node clientNode =
Client client = clientNode.client();
BulkRequestBuilder bulkRequest = client.prepareBulk();


You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit