我想删除与查询匹配的ElasticSearch中的数据。我使用ElasticSeach 1.5并执行此查询以实现以下目标:
POST employee/report/_delete_by_query
{
"query": {
"bool": {
"must": [
[
{ "match_phrase" : { "year_month" : "2016-8" } },
{ "term" : { "status" : "Inactive" } }
]
]
}
}
}当我这样做的时候,我得到了这样的结果:
{
"_index": "employee",
"_type": "report",
"_id": "_delete_by_query",
"_version": 6,
"created": false
}每次运行查询时,_version编号都会得到+1。然后查询删除的术语,以检查没有更多的结果:
GET employee/report/_search
{
"query": {
"bool": {
"must": [
[
{ "match_phrase" : { "year_month" : "2016-8" } },
{ "term" : { "status" : "Inactive" } }
]
]
}
}
}而且我还能得到结果!我做错什么了?我需要刷新ElasticSearch吗?我错过了一步?
发布于 2017-04-18 03:40:07
使用delete-by-query的正确方法如下所示,即您需要使用_query HTTP方法访问DELETE端点:
DELETE employee/report/_query
{
"query": {
"bool": {
"must": [
[
{ "match_phrase" : { "year_month" : "2016-8" } },
{ "term" : { "status" : "Inactive" } }
]
]
}
}
}https://stackoverflow.com/questions/43458053
复制相似问题