elasticsearch 在8.9版本的elastic中,“not”对应的语法是什么?

rvpgvaaj  于 7个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(91)

下面的语法来自2.2弹性版本,它工作正常。

{
    "bool" : {
        "must" : {
            "term" : { "name.first" : "shay" }
        },
        "filter" : {
            "not" : {
                "range" : {
                    "postDate" : {
                        "from" : "2010-03-01",
                        "to" : "2010-04-01"
                    }
                }
            }
        }
    }
}

字符串
最新版本的弹性不允许使用not,8.9版本的not子句对应的语法是什么?8.9中获取parsing_exception未知查询[not]

bxjv4tth

bxjv4tth1#

要排除过滤器,您可以使用must_not,因此您的搜索将如下所示,range也需要更新,请参阅docs

{
    "bool" : {
        "must" : [
            {
                "term" : { 
                    "name.first" : "shay" 
                }
            }
        ],
        "must_not": [
            {
                "range" : {
                    "postDate" : {
                        "gt" : "2010-03-01",
                        "lt" : "2010-04-01"
                    }
                }
            }
        ]
    }
}

字符串

相关问题