feat(新增): 删除索引库

This commit is contained in:
bunny 2024-03-31 19:58:18 +08:00
parent 025867af16
commit 2d01f995c8
4 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package cn.itcast.hotel;
import cn.itcast.hotel.constants.HotelConstants;
import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
@ -48,4 +49,15 @@ public class HotelIndexTest {
// 3. 发送请求
client.indices().create(request, RequestOptions.DEFAULT);
}
// 删除索引库
@Test
void deleteHotelIndex() throws IOException {
// 1. 创建Request对象
DeleteIndexRequest request = new DeleteIndexRequest("hotel");
// 2. 删除索引库
client.indices().delete(request, RequestOptions.DEFAULT);
}
}