Difference between using nested type in query with must_not

I've come across a scenario where I am returning fewer results when using a nested query for accessing the nested object data vs just using a normal terms query.

With the nested query it returns documents that I want excluded.

        "must_not": [
          {
            "nested": {
              "path": "images",
              "filter": {
                "bool": {
                  "must": [
                    {
                      "terms": {
                        "images.type": [
                          "BANNER",
                          "BANNER-2",
                          "BANNER-LOGO",
                          "ICONIC"
                        ]
                      }
                    }
                  ]
                }
              }
            }
          }
        ]

Without the nested query it works as expected.

    "must_not": [
      {
        "terms": {
          "images.type": [
            "BANNER",
            "BANNER-2",
            "BANNER-LOGO",
            "ICONIC"
          ]
        }
      } 

Any one know what 's going on here, I thought this logic would be identical. Basically we just want to return documents that don't have images of type BANNER, BANNER-2, BANNER-LOGO, or ICONIC.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.