【SpringCloud+RabbitMQ+Docker+Redis+搜索+分布式,系统详解springcloud微服务技术栈课程|黑马程序员Java微服务】
删除索引库代码如下:

//删除索引库
@Test
void testDeleteHotelIndex() throws IOException {
//1. 创建Request对象
DeleteIndexRequest request = new DeleteIndexRequest("hotel");
//2. 发送请求
client.indices().delete(request , RequestOptions.DEFAULT);
}

直接运行测试

又绿了
kibana 查

OK,404 了,删除成功了
判断索引库是否存在

//判断索引库是否存在
@Test
void testExistsHotelIndex() throws IOException {
//1. 创建Request对象
GetIndexRequest request = new GetIndexRequest("hotel");
//2. 发送请求
boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);
//3. 输出结果
System.err.println(exists ? "索引库已经存在" : "索引库不存在");
}

直接运行测试方法

没毛病【我们刚刚已经删除了hotel 索引库】
再创建一次

再次判断

没毛病
索引库操作的基本步骤: