# Valid use case for parent-child?

**URL:** <https://discuss.elastic.co/t/valid-use-case-for-parent-child/6356>\
**Category:** Elasticsearch\
**Created:** [January 11, 2012, 9:38pm UTC](https://discuss.elastic.co/t/valid-use-case-for-parent-child/6356 "2012-01-11T21:38:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Hoffman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick_hoffman/32/1872_2.png) [@Nick\_Hoffman](https://discuss.elastic.co/u/Nick_Hoffman)\
**Post date:** [January 11, 2012, 9:38pm UTC](https://discuss.elastic.co/t/valid-use-case-for-parent-child/6356/1 "2012-01-11T21:38:01Z")

</div>

Hey guys. I'm wondering if a parent-child relation is suitable for the  
problem that I'm trying to solve:

My application has 2 primary objects: Product, and Item. Each product has  
1+ items. Each item is associated with 1+ products.

When searching for products, the attributes of each product's items need to  
be considered. For example, if a product named "TF Gift Set" contains items  
named "Megatron" and "Grimlock", searching for "Megatron" should return  
this product.

In addition to searching through products' items, I'm trying to sort on  
fields within products' items. However, I don't think this is possible if a  
product contains more than 1 item. This is because sorting on items' "name"  
field in the previous example would return more than 1 name ("Megatron" and  
"Grimlock").

Is the parent-child feature suitable for what I'm trying to do? If it  
isn't, what do you guys recommend? I'm all ears!

Thanks,  
Nick

---

<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:43am UTC](https://discuss.elastic.co/t/valid-use-case-for-parent-child/6356/2 "2017-07-06T03:43:01Z")

</div>

Closed on July 6, 2017, 3:43am UTC


