添加依赖:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.6.2</version>
</dependency>
由于我使用的springboot版本对应的是6.8.5,所以maven中还要添加
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<elasticsearch.version>7.6.2</elasticsearch.version>
</properties>
初始化:
@Configuration
public class ESClient {
@Bean
public RestHighLevelClient client(){
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(
// new HttpHost("321.321.321.321", 9201, "http"),
new HttpHost("123.123.123.123", 9200, "http")));
return client;
}
}
ElasticSearch Java高级客户端RestHighLevelClient
原文:https://www.cnblogs.com/gqymy/p/12891257.html