索引-删除
# DeleteIndexRequest
创建 Test04_Index_Delete
package com.stt.demo;
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 Test04_Index_Delete {
public static void main(String[] args) throws IOException {
// 创建客户端
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(new HttpHost("localhost", 9200, "http"))
);
// 创建请求
DeleteIndexRequest request = new DeleteIndexRequest("user");
// 发送请求
AcknowledgedResponse response = client.indices().delete(request, RequestOptions.DEFAULT);
// 返回结果
System.out.println("操作返回:" + response.isAcknowledged());
// 关闭客户端
client.close();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
返回
操作返回:true
1
Last Updated: 2022/02/05, 15:58:51