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