# Parent child documents query

**URL:** https://discuss.elastic.co/t/parent-child-documents-query/21808
**Category:** Elasticsearch
**Created:** [January 23, 2015, 8:22pm UTC](https://discuss.elastic.co/t/parent-child-documents-query/21808 "2015-01-23T20:22:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)
#### Post date: [January 23, 2015, 8:22pm UTC](https://discuss.elastic.co/t/parent-child-documents-query/21808/1 "2015-01-23T20:22:49Z")

</div>

Is there a way we can get all child's and parents if parent /child  
qualifies for a query

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/35410b56-5334-4691-b966-b08402e284ba%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/35410b56-5334-4691-b966-b08402e284ba%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)
#### Post date: [January 24, 2015, 4:29pm UTC](https://discuss.elastic.co/t/parent-child-documents-query/21808/2 "2015-01-24T16:29:57Z")

</div>

For example:

Have three below documents , FakeDoc,Doc1&Doc2

Now how to write a query that qualifies Doc1 and also gets the all  
documents which has same parentid as Doc1

That is Doc1 and Doc2 in this case

FakeDoc{

F1

}

Doc1

{

\_parent:F1

}

Doc2

{

\_parent:F2

}

On Friday, 23 January 2015 15:22:49 UTC-5, bvnrwork wrote:

> Is there a way we can get all child's and parents if parent /child  
> qualifies for a query

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/32a3ac9e-409b-46df-af50-4ed6d8048bbc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/32a3ac9e-409b-46df-af50-4ed6d8048bbc%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Perryn\_Fowler](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@Perryn\_Fowler](https://discuss.elastic.co/u/Perryn_Fowler)
#### Post date: [January 27, 2015, 11:00pm UTC](https://discuss.elastic.co/t/parent-child-documents-query/21808/3 "2015-01-27T23:00:52Z")

</div>

You should be able to query the child type with a has\_parent query which  
has a has\_child query nested within it.

No idea how it would perform though.

On Sun, Jan 25, 2015 at 3:29 AM, bvnrwork [budda08nitt@gmail.com](mailto:budda08nitt@gmail.com) wrote:

> For example:
> 
> Have three below documents , FakeDoc,Doc1&Doc2
> 
> Now how to write a query that qualifies Doc1 and also gets the all  
> documents which has same parentid as Doc1
> 
> That is Doc1 and Doc2 in this case
> 
> FakeDoc{
> 
> F1
> 
> }
> 
> Doc1
> 
> {
> 
> \_parent:F1
> 
> }
> 
> Doc2
> 
> {
> 
> \_parent:F2
> 
> }
> 
> On Friday, 23 January 2015 15:22:49 UTC-5, bvnrwork wrote:
> 
> > Is there a way we can get all child's and parents if parent /child  
> > qualifies for a query
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/32a3ac9e-409b-46df-af50-4ed6d8048bbc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/32a3ac9e-409b-46df-af50-4ed6d8048bbc%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/32a3ac9e-409b-46df-af50-4ed6d8048bbc%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/32a3ac9e-409b-46df-af50-4ed6d8048bbc%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAFps6aBkkAUe%2BMqHKhJccnVPwKLTZBqEVY%2B3sBo96YenO\_CRnQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFps6aBkkAUe%2BMqHKhJccnVPwKLTZBqEVY%2B3sBo96YenO_CRnQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:36am UTC](https://discuss.elastic.co/t/parent-child-documents-query/21808/4 "2017-07-06T00:36:19Z")

</div>


