小编典典

在ElasticSearch查询中组合must_not

elasticsearch

我目前正在使用ElastSearch查询,该查询当前看起来如下所示:

...
"query": {
    "bool": {
        "must_not": [
            {
                "term": {
                    "bool-facet.criteria1": {
                        "value": false
                    }
                }
            },
            {
                "term": {
                    "bool-facet.criteria2": {
                        "value": false
                    }
                }
            }
        ]
    }
}
...

因此,现在当条件1或条件2匹配时,将忽略文档。查询的外观如何,以便仅忽略符合条件1和条件2的文档?


阅读 4140

收藏
2020-06-22

共1个答案

小编典典

由于不可能更新elasticsearch版本,因此我不得不找到另一个解决方案。这对我有用:

"query": {
    "bool": {
        "must_not" : [
            {
                "query": {
                    "bool": {
                        "must": [
                            {
                               "term": {
                                 "bool-facet.criteria1": false
                               }
                            },
                            {
                               "term": {
                                 "bool-facet.criteria2": false
                               }
                            }
                        ]
                    }
                }
            }
        ]
    }
}
2020-06-22