title: Elasticsearch: has_child query with children aggregation - bucket counts are wrong
body: <p>I'm attempting to find parents based on matches in their children and retrieve children term aggregations for the matches.  For some reason, the bucket count for the children aggregation is showing a higher count than actual results (I would be happy if it showed the count of the parents - or the children - in the particular children bucket).</p>
  
  <p>The query is similar to the following (NOTE: I use the filtered query as I will later add a filter in addition to the query):</p>
  
  <pre><code>{
  "query" : {
      "filtered" : {
          "query" : {
              "has_child" : {
              "type" : "blog_tag",
              "query" : {
                  "filtered" : {
                      "query" : {
                          "term" : {
                              "tag" : "something"
                          }
                      }
                  }
              }
          }
      }
  },
  "aggs" : {
      "my_children" : {
          "children" : {
              "type" : "my_child_type"
          },
          "aggs" : {
              "field_name" : {
                  "terms" : {
                      "field" : { "blog.blog_tag.field_name" }
                  }
              }
          }
      }
  }     
  </code></pre>
  
  <p>}</p>
  
  <p>What is the correct way to do this?</p>