ElasticSearch服务默认端口9300
Web管理平台端口9200
Code -> GitHub
https://github.com/liufengji/elasticsearch_api.git
private TransportClient client;
@SuppressWarnings("unchecked")
@Before
public void getClient() throws Exception {
// 1 设置连接的集群名称
Settings settings = Settings.builder().put("cluster.name",
"my-application").build();
// 2 连接集群
client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new InetSocketTransportAddress(
InetAddress.getByName("hadoop102"), 9300));
// 3 打印集群名称
System.out.println(client.toString());
}