title: Get mutiple field data from both parent and child in a single elasticsearch query
body: <p>Is it possible to get field data from both parent and child in a single elasticsearch query? Essentially what I am trying to capture the data for the multiple parent fields and multiple child fields in a single iteration with filtering. I tried various methods of binding the information into a single query but not able to figure out a way from it. Here is how my mapping looks like :-</p>
  
  <p>parent:</p>
  
  <pre><code>_id_parent : values {1}
  _source: {_date (20160316), _time (20160316010000), _id_source (test), _year (2016), _month (1)}
  </code></pre>
  
  <p>child:</p>
  
  <pre><code>_id_child : values {1}
  _source: {_id_child (1), _id_parent (1), _child_question (q1), _child_answer (This needs to be done.)}
  </code></pre>
  
  <p>Expected Output (something similar to below):</p>
  
  <pre><code>    (PARENT)
        "hits" : {
          "total" : 1,
          "max_score" : 1.0,
          "hits" : [ {
            "_index" : "index",
            "_type" : "parent",
            "_id" : "1",
            "_score" : 1.0,
            "_source":{_id_parent":"1","_id_source":"test","_date":"20160316","_time":"20160316010000","_year":2016,"_month":"1"}
          } ]
        }
          (CHILD)
            "hits" : {
              "total" : 1,
              "max_score" : 1.0,
              "hits" : [ {
                "_index" : "index",
                "_type" : "child",
                "_id" : "1",
                "_score" : 1.0,
                "_source":{"_id_child":"1", "_child_question":"q1","_child_answer":"This needs to be done."}
              } ]
            }
  </code></pre>
  
  <p>Links:</p>
  
  <p><a href="http://rore.im/posts/elasticsearch-joins/" rel="noreferrer">http://rore.im/posts/elasticsearch-joins/</a></p>
  
  <p><a href="https://github.com/elastic/elasticsearch/issues/761" rel="noreferrer">https://github.com/elastic/elasticsearch/issues/761</a></p>
  
  <p><a href="https://www.elastic.co/guide/en/elasticsearch/guide/current/children-agg.html" rel="noreferrer">https://www.elastic.co/guide/en/elasticsearch/guide/current/children-agg.html</a></p>
  
  <pre><code>    curl -XGET "$ELASTICSEARCH_ENDPOINT/index/parent/_search?pretty=true" -d "
      {
          "query": {
              "match": {
                  "_id_parent": "1"
                  }
              },
              "size" : 10,
              "aggs": {
                  "_id_parent": {
                      "terms": {
                          "field":"_id_parent",
                          "field":"_id_source",
                          "field":"_date",
                          "field":"_time",
                          "field":"_year",
                          "field":"_month",
                          },
                      "aggs": {
                          "child": {
                              "children": {
                                  "type": "child"
                                  },
                              "aggs": {
                                  "child": {
                                      "terms": {
                                          "field": "child._id_child",
                                          "field": "child._child_question",
                                          "field": "child._child_answer",
                                  }
                              }
                          }
                      }
                  }
              }
          }
      }"
  </code></pre>