package com.atguigu.es.test;
import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import java.io.IOException;
public class ESTest_Index_Delete {
public static void main(String[] args) throws IOException {
//创建ES客户端
HttpHost httpHost = new HttpHost("localhost", 9200, "http");
RestHighLevelClient esClient = new RestHighLevelClient(RestClient.builder(httpHost));
//删除索引
DeleteIndexRequest request = new DeleteIndexRequest("user2");
//删除索引后的回复
AcknowledgedResponse status = esClient.indices().delete(request, RequestOptions.DEFAULT);
//相应状态
System.out.println("应答状态显示:"+status.isAcknowledged());
//关闭ES客户端
esClient.close();
}
}
本文转载自: https://blog.csdn.net/weixin_43882788/article/details/126574507
版权归原作者 永远的HelloWorld 所有, 如有侵权,请联系我们删除。
版权归原作者 永远的HelloWorld 所有, 如有侵权,请联系我们删除。