# Parent/Child with one to many?

**URL:** https://discuss.elastic.co/t/parent-child-with-one-to-many/4312
**Category:** Elasticsearch
**Created:** [April 28, 2011, 7:53pm UTC](https://discuss.elastic.co/t/parent-child-with-one-to-many/4312 "2011-04-28T19:53:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![James\_K](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james_k/32/2129_2.png) [@James\_K](https://discuss.elastic.co/u/James_K)
#### Post date: [April 28, 2011, 7:53pm UTC](https://discuss.elastic.co/t/parent-child-with-one-to-many/4312/1 "2011-04-28T19:53:15Z")

</div>

Hello all, I'm trying to understand whether the parent child  
functionality in elastic search will suit my needs or if I'm barking  
up the wrong tree.

I have an index on forum posts with the body, user\_id of the author.  
I'd like to create an index on users (with age, gender etc) so that i  
can search for posts containing a keyword that were created by a user  
of a certain age.

At a high level, I'd like to do a search on posts with a has\_child  
query on a related user object. The problem here is that the user  
would need many parents, do this doesn't seem to fit the model.

Anyone have any ideas on this?

thanks

-James

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [April 29, 2011, 8:49pm UTC](https://discuss.elastic.co/t/parent-child-with-one-to-many/4312/2 "2011-04-29T20:49:44Z")

</div>

Yea, it does not seem to fit the model. You should denoarmalize the posts and add the relevant user data to it.  
On Thursday, April 28, 2011 at 10:53 PM, James K wrote:

> Hello all, I'm trying to understand whether the parent child  
> functionality in Elasticsearch will suit my needs or if I'm barking  
> up the wrong tree.
> 
> I have an index on forum posts with the body, user\_id of the author.  
> I'd like to create an index on users (with age, gender etc) so that i  
> can search for posts containing a keyword that were created by a user  
> of a certain age.
> 
> At a high level, I'd like to do a search on posts with a has\_child  
> query on a related user object. The problem here is that the user  
> would need many parents, do this doesn't seem to fit the model.
> 
> Anyone have any ideas on this?
> 
> thanks
> 
> -James

---

<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, 4:07am UTC](https://discuss.elastic.co/t/parent-child-with-one-to-many/4312/3 "2017-07-06T04:07:22Z")

</div>


