Elasticsearch根据条件进行删除索引命令

以前都是按照索引中文档的id进行删除,其实Elasticsearch支持按照条件进行删除操作:
删除索引中某个type的符合条件记录:

curl -XDELETE http://localhost:9200/indexname/typename/_query?pretty -d '{
"query":{
    "filtered":{
        "filter":{
            "bool":{
                "must":{
                    "range":{
                        "logtime":{
                            "gt":"20171214235459",
                            "lt":"20171215235959"
                        }
                    }
                }
            }
        }
    }
}
}';

删除索引中所有的符合条件记录:

curl -XDELETE http://localhost:9200/indexname/_query?pretty -d '{
"query":{
    "filtered":{
        "filter":{
            "bool":{
                "must":{
                    "range":{
                        "logtime":{
                            "gt":"20171214235459",
                            "lt":"20171215235959"
                        }
                    }
                }
            }
        }
    }
}
}';

猜你喜欢

转载自blog.51cto.com/11091005/2126883
今日推荐