title: Term, nested documents and must_not query incompatible in ElasticSearch?
body: <p>I have trouble combining term, must_not queries on nested documents.</p>
  
  <p>Sense example can be found here : <a href="http://sense.qbox.io/gist/be436a1ffa01e4630a964f48b2d5b3a1ef5fa176" rel="nofollow noreferrer">http://sense.qbox.io/gist/be436a1ffa01e4630a964f48b2d5b3a1ef5fa176</a></p>
  
  <p>Here my mapping : </p>
  
  <pre><code>{
      "mappings": {
          "docs" : {
              "properties": {
                  "tags" : {
                      "type": "nested",
                      "properties" : {
                          "type": {
                             "type": "string",
                             "index": "not_analyzed"
                          }
                      }
                  },
                  "label" : {
                      "type": "string"
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>with two documents in this index :</p>
  
  <pre><code>{
      "tags" : [
          {"type" : "POST"},
          {"type" : "DELETE"}
      ],
      "label" : "item 1"
  },
  {
      "tags" : [
          {"type" : "POST"}
      ],
      "label" : "item 2"
  }
  </code></pre>
  
  <p>When I query this index like this :</p>
  
  <pre><code>{
    "query": {
      "nested": {
        "path": "tags",
        "query": {
          "bool": {
            "must": {
              "term": {
                "tags.type": "DELETE"
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p><strong>I've got one hit (which is correct)</strong></p>
  
  <p>When I want to get documents WHICH DON'T CONTAIN the tag "DELETE", with this query :</p>
  
  <pre><code>{
    "query": {
      "nested": {
        "path": "tags",
        "query": {
          "bool": {
            "must_not": {
              "term": {
                "tags.type": "delete"
              }
            }
          }
        }
      }
    }
  }
  </code></pre>
  
  <p><strong>I've got 2 hits (which is incorrect).</strong>
  This issue seems very close to this one (<a href="https://stackoverflow.com/questions/21168375/elasticsearch-array-must-and-must-not">Elasticsearch array must and must_not</a>) but it's not...</p>
  
  <p>Can you give me some clues to resolve this issue ?</p>
  
  <p>Thank you</p>