elasticsearch-dsl:如何对过滤器进行取反

3

我有一个类似这样的查询

   s = Search(using=es, index=indices)
   s = s.filter('range', 
                utctimestamp={'gte': begindateUTC, 'lte': enddateUTC})
         .filter("term",tags="foo").
         .sort("-utctimestamp")

我的问题是,如何否定过滤器?即不是foo。 上述内容必须使用过滤器,例如:
  "filter": {
    "bool": {
      "must": [
        {
          "range": {
            "utctimestamp": {
              "from": 1460407864660,
              "to": 1460409664660
            }
          }
        },
        {
          "fquery": {
            "query": {
              "query_string": {
                "query": "_type:(\"foo\")"
              }
            },
            "_cache": true
          }
        }
      ]

如何使“foo”位为“必须不”。

提前感谢。

1个回答

6

你应该在must_not语句中使用筛选器。

must_not语句不影响得分,它们的唯一目的是排除那些本来可能被包含的文档。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接