我正在尝试使用 Elasticsearch Java NodeBuilder Client 连接到我的服务器。但是我没有看到任何指定我的服务器地址和端口的选项(就像我们可以在传输客户端中使用addNewTransportAddress("serveraddress", port))
. 如何使节点客户端连接到我的服务器?代码如下,我在哪里提到要连接到的服务器地址?
//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());