Search for documents containing an item not present in a list

Hi @Adrian_Fresco

I adapted the query by this post. Try please.

{
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "fruits",
            "query": {
              "bool": {
                "must_not": [
                  {
                    "terms": {
                      "fruits.name": [
                        "apple",
                        "pineapple",
                        "grape",
                        "orange",
                        "pear"
                      ]
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}
1 Like