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

问题描述 投票:0回答:1

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

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

8.9版本的not子句对应的语法是什么,因为最新版本的elastic不允许使用not。 在 8.9 中[未]获取 parsing_exception 未知查询

elasticsearch elastic-stack elasticsearch-aggregation elasticsearch-dsl
1个回答
0
投票

要排除过滤器,您可以使用

must_not
,这样您的搜索将如下所示,
range
也需要更新,请参阅docs

{
    "bool" : {
        "must" : [
            {
                "term" : { 
                    "name.first" : "shay" 
                }
            }
        ],
        "must_not": [
            {
                "range" : {
                    "postDate" : {
                        "gt" : "2010-03-01",
                        "lt" : "2010-04-01"
                    }
                }
            }
        ]
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.