如何删除包含多个条件的索引?

b09cbbtk  于 2021-06-15  发布在  ElasticSearch
关注(0)|答案(1)|浏览(371)

我尝试删除满足所选条件的指定索引。
目前,我删除他们使用如下所示的一个条件

localhost:9200/pictures/picture/_delete_by_query?pretty
{
    "query": {
        "regexp":{
                "tag": ".*something.*"
            }
        }
    }
}

我想以这种方式删除它们

localhost:9200/pictures/picture/_delete_by_query?pretty
{
    "query": {
        "regexp":{
                "tag": ".*something.*",
                "path": "this/is/my/path",
                "user_id": 2,

            }
        }
    }
}

你知道我怎么做吗?

fcy6dtqo

fcy6dtqo1#

我想使用bool查询是正确的方向,类似这样的方法应该可以:

localhost:9200/pictures/picture/_delete_by_query?pretty
{
    "query": {
        "bool": {
            "must": [
                {
                    "regexp":{
                            "tag": ".*something.*",
                            "path": "this/is/my/path",
                            "user_id": 2,

                        }
                    }               
                },
                {
                    "term": {
                        "path.keyword": "this/is/my/path"
                    }
                },
                {
                    "term": {
                        "user_id.keyword": 2
                    }               
                }
            ]
        }
    }
}

相关问题