# Query encompassing both parent and child documents

**URL:** https://discuss.elastic.co/t/query-encompassing-both-parent-and-child-documents/10399
**Category:** Elasticsearch
**Created:** [January 17, 2013, 9:11pm UTC](https://discuss.elastic.co/t/query-encompassing-both-parent-and-child-documents/10399 "2013-01-17T21:11:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)
#### Post date: [January 17, 2013, 9:11pm UTC](https://discuss.elastic.co/t/query-encompassing-both-parent-and-child-documents/10399/1 "2013-01-17T21:11:48Z")

</div>

hi, is it possible to have a query that covers both parent and child  
documents? e.g., if i have parent docs for blogs and child docs for  
comments on each blog doc, then is it possible to do a query that searches  
both in the blog post and comments?

the has\_child query works fine by itself but i am not able to figure out  
how to combine the two.

thanks

--

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [January 18, 2013, 9:25am UTC](https://discuss.elastic.co/t/query-encompassing-both-parent-and-child-documents/10399/2 "2013-01-18T09:25:35Z")

</div>

Hiya

On Thu, 2013-01-17 at 13:11 -0800, T Vinod Gupta wrote:

> hi, is it possible to have a query that covers both parent and child  
> documents? e.g., if i have parent docs for blogs and child docs for  
> comments on each blog doc, then is it possible to do a query that  
> searches both in the blog post and comments?
> 
> the has\_child query works fine by itself but i am not able to figure  
> out how to combine the two.

Do you mean that you want both blog and comment docs to be returned from  
the same query?

There are various ways of approaching this problem, but it kinda depends  
what you're trying to achieve. If you could be more specific, it'd be  
easier to provide suggestions

clint

--

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 2:55am UTC](https://discuss.elastic.co/t/query-encompassing-both-parent-and-child-documents/10399/3 "2017-07-06T02:55:49Z")

</div>


