I want to combine must and must_not with AND in one bool query. I want to get those records whose name is john and no must not equal to 1

tried below but not worked

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

got

{
    "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 Answers