Elasticsearch-删除操作
# 语法格式
DELETE customer/external/1
DELETE customer
1
2
2
# 删除文档请求实例
- 请求路径 DELETE请求
http://192.168.56.10:9200/customer/external/1
1
- 返回Status:200 OK
{
"_index": "customer",
"_type": "external",
"_id": "1",
"_version": 6,
"result": "deleted",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 11,
"_primary_term": 1
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
当删除成功后,再去查询这条数据
GET http://192.168.56.10:9200/customer/external/1
1
- 返回Status:404 Not Found
{
"_index": "customer",
"_type": "external",
"_id": "1",
"found": false //没有找到这条数据
}
1
2
3
4
5
6
2
3
4
5
6
# 删除索引
ES并未提供删除类型的操作,只有删除文档后者索引
- 请求路径
http://192.168.56.10:9200/customer
1
- 返回Status:200 OK
{
"acknowledged": true
}
1
2
3
2
3
这时候,再去查询数据,返回Status:404 Not Found
{
"error": {
"root_cause": [
{
"type": "index_not_found_exception",
"reason": "no such index [customer]",
"resource.type": "index_expression",
"resource.id": "customer",
"index_uuid": "_na_",
"index": "customer"
}
],
"type": "index_not_found_exception",
"reason": "no such index [customer]",
"resource.type": "index_expression",
"resource.id": "customer",
"index_uuid": "_na_",
"index": "customer"
},
"status": 404
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
帮我改善此页面 (opens new window)
上次更新: 2020/12/17, 08:38:35