title: Query documents that contains all values in nested array Elasticsearch
body: <p>I'm trying to query documents where the nested array contains all of the elements passed in the query.</p>
  
  <p>The index stores groups and each group has a list of members. I want to query all the groups that contains the given members.</p>
  
  <p>Mapping:</p>
  
  <pre><code>"properties" : {
     "members" : {
        "type" : "nested",
        "properties" : {
           "name" : {
              "type" : "keyword"
           }
         }
      },
      "name" : {
          "type" : "text"
       }
     }
    }
  }
  </code></pre>
  
  <p>Example content:</p>
  
  <pre><code>[
    {
      "name" : "group 1",
      "members" : [
        {
          "name" : "alice"
        },
        {
          "name" : "bob"
        }
      ]
    },
    {
      "name" : "group 2",
      "members" : [
        {
          "name" : "alice"
        },
        {
          "name" : "foo"
        },
        {
          "name" : "bob"
        }
      ]
    },
    {
      "name" : "group 3",
      "members" : [
        {
          "name" : "foo"
        },
        {
          "name" : "bar"
        }
      ]
    }
  ]
  </code></pre>
  
  <p>How can I find all groups that have both "alice" and "foo" as members?</p>
  
  <p>I have tried the following query but it returns nothing:</p>
  
  <pre><code>GET /group/_search
  {
    "query": {
      "nested": {
        "path": "members",
        "query": {
          "bool": {
            "must": [
              {"match": {"members.name": "alice"}},
              {"match": {"members.name": "foo"}}
            ]
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>I have also tried with <code>term</code> instead of <code>match</code> but it gives no results.</p>