ElasticSearch7.X Java client


<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.2.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.2.0</version>
</dependency>


import org.apache.http.HttpHost; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestHighLevelClient; /** * @author * @version 1.0 * @description TODO * @date 2020/4/19 20:38 **/ public class EsClient { private static RestHighLevelClient client = null; public static synchronized RestHighLevelClient getEsClient() { if (client == null){ client = new RestHighLevelClient(RestClient.builder( new HttpHost("192.168.242.20", 9200, "http") )); } return client; } }

 

posted on 2020-04-23 21:32  0x153_小波  阅读(2110)  评论(0编辑  收藏  举报