Get both parent and child document

Is it possible to return both parent data and child with an Elasticsearch query?
Example :

PUT my_index/posts/_search { { "query": { "has_child": {"type": "comments"}}}}

It will return only posts data. How can I get the comments data too?

You can use inner hits for this:

{
   "query" : {
       "has_child" : {
          "type" "comments",
          "inner_hits" : {}
      }
}

This will include per post hit the top 3 matching comment hits.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.