简体   繁体   English

弹性搜索中的过滤查询

[英]Filtered Query in Elastic Search

Filtered Query query not working in elastic search. 筛选查询查询在弹性搜索中不起作用。 It gives a error Query Parsing exception with filter malformed, no field after start_object 它给出错误的查询解析异常,过滤器格式错误,start_object之后没有字段

{
"query": {
  "filtered": {
    "query": {
      "match_all": {}
    },
    "filter": {
      "bool": {
        "must": [],
        "should": [
          {
            "_expires": null
          },
          {
            "_expires": {
              "gte": 1433947304884
            }
          }
        ],
        "must_not": [
          {
            "term": {
              "age": 19
            }
          }
        ]
      }
    }
  }
},
"size": 10,
"from": 0
}

Can somebody help me with this? 有人可以帮我吗?

Your should s should be actually using a filter. should也应该被实际使用的过滤器。 For yours you have "_expires": null . 对于您来说,您有"_expires": null This is not a filter. 这不是过滤器。

For example, try: 例如,尝试:

        {
          "missing": {
            "field": "_expires"
          }
        },
        {
          "range": {
            "_expires": {
              "gte": 1433947304884
            }
          }
        }

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

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