Elasticsearch布尔查询组合必须和必须不起作用

时间:2019-05-18 14:25:38

标签: elasticsearch elastic-stack

我想在一个布尔查询中将must和must_not与AND结合在一起。我想获取那些名称为john且不可以不等于1的记录

在下面尝试过但没用

{
    "query": {
        "bool": {
            "must": [{
                "query_string": {
                    "query": "*alen*",
                    "fields": [
                        "name"
                    ]
                }
            }],
            "must_not": [{
                "match": {
                    "no": "1"
                }
            }]
        }
    }
}

得到

{
    "took": 5,
    "timed_out": false,
    "_shards": {
      "total": 1,
      "successful": 1,
      "skipped": 0,
      "failed": 0
    },
    "hits": {
      "total": {
        "value": 0,
        "relation": "eq"
      },
      "max_score": null,
      "hits": []
    }
  }

0 个答案:

没有答案