# Help with Parent/Child (gist included!)

**URL:** <https://discuss.elastic.co/t/help-with-parent-child-gist-included/5583>\
**Category:** Elasticsearch\
**Created:** [October 13, 2011, 3:00am UTC](https://discuss.elastic.co/t/help-with-parent-child-gist-included/5583 "2011-10-13T03:00:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_smith/32/1323_2.png) [@Paul\_Smith](https://discuss.elastic.co/u/Paul_Smith)\
**Post date:** [October 13, 2011, 3:00am UTC](https://discuss.elastic.co/t/help-with-parent-child-gist-included/5583/1 "2011-10-13T03:00:34Z")

</div>

Hey all, a while back I posted this question about Parent/Child use case:

[http://elasticsearch-users.115913.n3.nabble.com/Parent-Child-use-case-td3347346.html](http://elasticsearch-users.115913.n3.nabble.com/Parent-Child-use-case-td3347346.html)

I've created a gist curl example to walk anyone through the thing I'm trying  
to do:

> <https://gist.github.com/tallpsmith/1283195>

In essense, I have 2 types, a 'doc' (parent) and a 'filecontent' (child)  
within the same index. I'd like to be able to search both types in 1 query,  
but if a match is found on the child, the results come back with the parent  
record only, with all results sorted by fields in the parent.

I've got multiple issues here:

a) the final search query doesn't work, so clearly I have no idea what I'm  
doing with respect to this top\_children query  
b) i'm not sure if I'm misinterpretting the way the parent/child is supposed  
to work

I've set the child mapping to point to the parent type as indicated in the  
docs for the \_parent type. I'm presuming the routing is then taken care of  
so the indexing of the child filecontent record can be routed to the same  
shard as the parent (doc) record for searching later on.

I've tried hard to read the docs in elasticsearch on the parent/child  
mapping, and I maybe just a bonehead here. This is a fairly critical use  
case for us in the future, we don't index the file content at the moment  
because it's hundreds of millions of records and an awful lot of content, so  
do not want continuous meta-data record changes being indexed to require  
retrieving and indexing file content over and over and over again.

Many thanks to anyone that can help here.

cheers,

Paul Smith

---

<div class="post-metadata">

**Author:** ![micuenta99](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@micuenta99](https://discuss.elastic.co/u/micuenta99)\
**Post date:** [November 15, 2011, 4:24pm UTC](https://discuss.elastic.co/t/help-with-parent-child-gist-included/5583/2 "2011-11-15T16:24:20Z")

</div>

Hi Paul,

I also am interested in this scenario ( 'doc' (parent) and a 'filecontent' (child))  
At the end how you did it do?

Thanks,

---

<div class="post-metadata">

**Author:** ![Paul\_Smith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_smith/32/1323_2.png) [@Paul\_Smith](https://discuss.elastic.co/u/Paul_Smith)\
**Post date:** [November 20, 2011, 1:10am UTC](https://discuss.elastic.co/t/help-with-parent-child-gist-included/5583/3 "2011-11-20T01:10:10Z")

</div>

Still haven't solved this but only because I have not brought myself back  
to working on this (for us it's a bit of a longer term project, not  
pressing need right this second).

On 16 November 2011 03:24, micuenta99 [micuenta99@gmail.com](mailto:micuenta99@gmail.com) wrote:

> Hi Paul,
> 
> I also am interested in this scenario ( 'doc' (parent) and a 'filecontent'  
> (child))  
> At the end how you did it do?
> 
> Thanks,
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Help-with-Parent-Child-gist-included-tp3417592p3510186.html](http://elasticsearch-users.115913.n3.nabble.com/Help-with-Parent-Child-gist-included-tp3417592p3510186.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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, 3:48am UTC](https://discuss.elastic.co/t/help-with-parent-child-gist-included/5583/4 "2017-07-06T03:48:11Z")

</div>


