title: Return parent data with child document from Elasticsearch
body: <p>Is is possible to return parent data with a search for child documents within an Elasticsearch query?</p>
  
  <p>I have two document types, e.g. Book and Chapter, that are related as Parent/Child (not nested). </p>
  
  <p>I want to run a search on the child document and return the child document, with some of the fields from the parent document. I'm trying to avoid executing a separate query on the parent.</p>
  
  <p><strong>Update</strong></p>
  
  <p>The only way possible I can find is to use the <code>has_child</code> query and then a series of aggregations to drill back to the children and apply the query/filter again. However, this seems overly complicated and inefficient.</p>
  
  <pre><code>GET index/_search
  {
    "size": 10,
    "query": {
      "has_child": {
        "type": "chapter",
    "query": {
      "term": {
        "field": "value"
          }
        }
      }
    },
    "aggs": {
  "name1": {
    "terms": {
      "size": 50,
      "field": "id"
    },
    "aggs": {
      "name2": {
        "top_hits": {
          "size": 50
        }
      },
      "name3": {
        "children": {
          "type": "type2"
        },
        "aggs": {
          "docFilter": {
            "filter": {
              "query": {
                "match": {
                  "_all": "value"
                }
              }
            },
            "aggs": {
              "docs": {
                "top_hits": {
                  "size": 50
                }
              }
            }
          }
        }
      }
    }
  }
    }
  }
  </code></pre>