@SpringBootTestpublic class MyTest{//注入RestHighLevelClient对象@Autowiredprivate RestHighLevelClient restHighLevelClient;@Testpublic void test() throws IOException {//创建GetIndexRequest请求对象,并指定索引库名GetIndexRequest getIndexRequest = new GetIndexRequest(索引库名);//发送请求,得到响应boolean isExist = restHighLevelClient.indices().exists(getIndexRequest, RequestOptions.DEFAULT);//输出结果System.err.println(isExist ? "索引库已存在" : "索引库不存在");}}
