ES delete_by_query条件删除的几种方式
es 查询删除的几种方式
1.根据id删除
#根据id删除
POST /indexname/_delete_by_query
{
"query": {
"match": {
"id": "100000"
}
}
}
2.根据多个id删除
#根据多个id删除
POST /indexname/_delete_by_query
{
"query": {
"bool": {
"filter": [
{
"terms": {
"id": [
"100000",
"200000"
]
}
}
]
}
}
}
3.根据多个id范围删除
#根据多个id范围删除
POST /indexname/_delete_by_query
{
"query": {
"range": {
"id": {
"gte": 100000,
"lte": 200000
}
}
}
}
注意:删除完成后,执行以下脚本回收索引空间
curl -XPOST http://127.0.0.1:9200/indexname/_forcemerge?max_num_segments=1