参考:https://blog.csdn.net/CYK_byte/article/details/133255773
java pom依赖:
xml
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.17.22</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-high-level-client -->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.17.22</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
</dependency>
<!-- <!– 添加Elasticsearch Core的依赖 –>-->
<!-- <dependency>-->
<!-- <groupId>org.elasticsearch</groupId>-->
<!-- <artifactId>elasticsearch</artifactId>-->
<!-- <version>7.17.22</version>-->
<!-- </dependency>-->
<!-- <!– https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-elasticsearch –>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-elasticsearch</artifactId>-->
<!-- <version>3.2.5</version>-->
<!-- </dependency>-->
初始化 RestHighLevelClient
这里我们创建一个测试类 HotelIndexTest ,用来演示 RestClient 操作的相关方法.