# Parent-child question

**URL:** <https://discuss.elastic.co/t/parent-child-question/4166>\
**Category:** Elasticsearch\
**Created:** [March 28, 2011, 9:05pm UTC](https://discuss.elastic.co/t/parent-child-question/4166 "2011-03-28T21:05:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lee\_Parker](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lee_parker/32/3250_2.png) [@Lee\_Parker](https://discuss.elastic.co/u/Lee_Parker)\
**Post date:** [March 28, 2011, 9:05pm UTC](https://discuss.elastic.co/t/parent-child-question/4166/1 "2011-03-28T21:05:53Z")

</div>

I have a situation and I'm trying to figure out if a parent-child setup is  
the way to go. We have a document called a stream\_item. It has some natural  
attributes that are true no matter where we show that item. The item can  
belong to more than one stream and within a stream it may have some  
different attributes. One example of a synthetic attribute is a read/unread  
flag. If a user marks an item as read within one stream, another user still  
needs to see the item as unread. If the first user wants to search for all  
unread items that match a particular phrase, I want to do a filtered search  
in ES that filters for all documents that are unread when in the context of  
this stream. I could certainly have a separate document per stream per  
stream item, but I'm trying to avoid document duplication. Could the  
"read/unread" status live in a stream specific child document? Would this  
be slower than simply duplicating the document?

## Lee

"It doesn't matter whether you are liberal or conservative, but it's  
dangerous to always think with exclamation points instead of question  
marks."  
by Marty Beckerman

---

<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:** [March 30, 2011, 6:30pm UTC](https://discuss.elastic.co/t/parent-child-question/4166/2 "2011-03-30T18:30:46Z")

</div>

Yes, it can certainly be a child document. The has\_child filter is more heavyweight then your "typical filter", you will need to run some perf tests to see that it works for you.  
On Monday, March 28, 2011 at 11:05 PM, Lee Parker wrote:

> I have a situation and I'm trying to figure out if a parent-child setup is the way to go. We have a document called a stream\_item. It has some natural attributes that are true no matter where we show that item. The item can belong to more than one stream and within a stream it may have some different attributes. One example of a synthetic attribute is a read/unread flag. If a user marks an item as read within one stream, another user still needs to see the item as unread. If the first user wants to search for all unread items that match a particular phrase, I want to do a filtered search in ES that filters for all documents that are unread when in the context of this stream. I could certainly have a separate document per stream per stream item, but I'm trying to avoid document duplication. Could the "read/unread" status live in a stream specific child document? Would this be slower than simply duplicating the document?
> 
> ## Lee
> 
> "It doesn't matter whether you are liberal or conservative, but it's dangerous to always think with exclamation points instead of question marks."  
> by Marty Beckerman

---

<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:09am UTC](https://discuss.elastic.co/t/parent-child-question/4166/3 "2017-07-06T04:09:06Z")

</div>

Closed on July 6, 2017, 4:09am UTC


