繁体   English   中英

elasticsearch must_not子句特别不适用于空字符串“”作为值

[英]elasticsearch must_not clause specifically does not work with empty string “” as value

基本上如标题所述。 我已经确认must_not确实可以工作,如果我指定一个带有一些非空字符串的字符串作为该字段不能匹配的内容。 这有效:

query=dict(
   bool=dict(
        must_not=dict(
            term=dict(
               {"platform_base": "cats"}
            ),
        ),
    ),
),

相反,如果我想排除所有将platform_base设置为空字符串“”的条目,如下所示:

actual_query = dict(
     query=dict(
         bool=dict(
             must_not=dict(
                  term=dict(
                       {"platform_base": ""}
                  ),
             ),
         ),
     ),
 )

突然,它不起作用,没有应用must_not过滤器,并且返回了将platform_base设置为“”的条目。 这是预期的行为吗? 如何获得所需的结果?

{
   "query" : {
       "regexp":{
           "<your_field_name_here>": ".+"
        }
    }
}  

做到了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM