title: multi value nested field Aggregation in elasticsearch
body: <p>I meet a quite special problem when using aggregation on a multi value and   nested filed in elasticsearch 5.6, and my index mapping is below:</p>
  
  <pre><code>{
  "my_index": {
    "mappings": {
      "my_type": {
        "properties": {
          "my_field": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "text",
                "fields": {
                  "keyword": {
                    "type": "keyword",
                    "ignore_above": 256
                  }
               }
             },
             "country": {
               "type": "text",
               "fields": {
                 "keyword": {
                   "type": "keyword",
                   "ignore_above": 256
                 }
               }
             },
           }
         }
       }
     }
   }
  }
  </code></pre>
  
  <p>and my data is like this :</p>
  
  <pre><code>"my_field": [
    {"name": "apple", "country": "USA"},
    {"name": "alibaba", "country": "CHINA"}
  ]
  </code></pre>
  
  <p>the requirement is that: I get a query word e.g. <strong>apple</strong>, and I use this query word to search on filed <strong>name</strong>, finally , I want to aggregation on <strong>country</strong> whose <strong>name</strong> is the query word <strong>apple</strong>. my query shows below:</p>
  
  <pre><code>{"query": {
  "nested": {"path": "my_field", "query": {"bool": {"should": [{"match": {"my_field.name.keyword": "apple"}}]}}}},
   "aggs": {"m_agg": {"nested": {"path": "my_field"},
                      "aggs": {"m1_agg": {"terms": {"field": "my_field.country.keyword"}}}}}}
  </code></pre>
  
  <p>so the input is <strong>apple</strong>, and the expect result is </p>
  
  <pre><code>"aggregations" : {
  "m_agg" : {
    "doc_count" : 1,
    "m1_agg" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "USA",
          "doc_count" : 1
        }
      ]
    }
  }
  }
  </code></pre>
  
  <p>but the elasticsearch returns the result :</p>
  
  <pre><code>"aggregations" : {
  "m_agg" : {
    "doc_count" : 2,
    "m1_agg" : {
      "doc_count_error_upper_bound" : 0,
      "sum_other_doc_count" : 0,
      "buckets" : [
        {
          "key" : "USA",
          "doc_count" : 1
        },
        {
          "key" : "CHINA",
          "doc_count" : 1
        }
      ]
    }
  }
  }
  </code></pre>
  
  <p>How to change the query DSL, to get the expect result?</p>