package cn.com.etl;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import java.net.InetAddress;
import java.net.InetSocketAddress;
public class HelloWorld {
public static void main(String[] args)throws Exception {
Settings settings = Settings.builder()
.put("cluster.name","my-es")
.build();
//创建client
TransportClient client = new PreBuiltTransportClient(settings).addTransportAddresses(
//用java访问ES用的端口是9300
new TransportAddress(new InetSocketAddress(InetAddress.getByName("192.168.64.11"), 9300)),
new TransportAddress(new InetSocketAddress(InetAddress.getByName("192.168.64.12"), 9300)),
new TransportAddress(new InetSo
6.3.0版本Elasticsearch:使用JAVA API连接集群
最新推荐文章于 2022-04-25 08:29:38 发布
本文详细介绍了如何在Elasticsearch 6.3.0版本中,利用JAVA API建立并管理到集群的连接。通过实例代码,展示了配置连接参数、创建客户端以及执行CRUD操作的步骤,为开发者提供了实用的参考。

最低0.47元/天 解锁文章
270

被折叠的 条评论
为什么被折叠?



