I am trying to connect to my server using Elasticsearch Java NodeBuilder Client. However I do not see any option to specify my server address and port (like we can do in Transport Client, using addNewTransportAddress("serveraddress", port))
. How do I make Node Client connect to my server? Code is below, where do I mention the server address to connect to?
//On Startup
Node node = nodeBuilder()
.clusterName("elasticsearch")
.data(false) //No shards allocated; or can set client to true
.client(true) //No shards allocated; or can set data to false
.node();
//Node Client
Client client = node.client();
//Get API
GetResponse response = client.prepareGet("indexname", "type", "id")
.execute()
.actionGet();
System.out.println("----------------Index Output Begin----------------");
System.out.println("Index Name: " + response.getIndex());
System.out.println("Type: " + response.getType());
System.out.println("Document ID: " + response.getId());
System.out.println("Document Version: " + response.getVersion());
System.out.println("Source: " + response.getSourceAsString());