@SpringBootTestclassJavaEsApplicationTests {
@AutowiredprivateRestHighLevelClient restHighLevelClient;/*** ES索引数据库,提供RestAPI
* POST 创建
* PUT 修改
* DELETE 删除
* GET 查询*/
//创建索引库
@Testvoid creteIndex() throwsIOException {//先发送一个创建索引库的请求,test是索引库的名字
CreateIndexRequest request = new CreateIndexRequest("test");//通过核心对象创建索引库
CreateIndexResponse response =restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);//ACK 确认
System.out.println(response.isAcknowledged());
}//判断索引库是否存在
@Testvoid isExists() throwsIOException {
GetIndexRequest test= new GetIndexRequest("test");boolean exists =restHighLevelClient.indices().exists(test, RequestOptions.DEFAULT);
System.out.println(exists);
}//删除索引库
@Testvoid deleteIndex() throwsIOException {//发