# Best practises for indexing relationships between objects

**URL:** <https://discuss.elastic.co/t/best-practises-for-indexing-relationships-between-objects/5342>\
**Category:** Elasticsearch\
**Created:** [September 10, 2011, 4:04pm UTC](https://discuss.elastic.co/t/best-practises-for-indexing-relationships-between-objects/5342 "2011-09-10T16:04:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haensel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/haensel/32/2595_2.png) [@Haensel](https://discuss.elastic.co/u/Haensel)\
**Post date:** [September 10, 2011, 4:04pm UTC](https://discuss.elastic.co/t/best-practises-for-indexing-relationships-between-objects/5342/1 "2011-09-10T16:04:33Z")

</div>

Hi,

After spending a lot of time thinking about a solution I decided to ask you  
guys for help.

I use a graph database (Neo4j) to define things that belong to categories  
and subcategories. Each category has properties (for example  
'productname','price') etc. with a certain datatype. A subcategory inherits  
from its parentcategory thus getting all properties the parentcategory has.  
Let's assume I use an index called 'things'.

I'll use one type for each category (for example things/cds,things/books  
etc.) which means I'll have to reindex each type with a new mapping if the  
category or a parentcategory changes a property - that's ok, although a bit  
clumsy of course.  
Now here comes the hard part: What if I would like to have a product that  
itself is a collection of other products like a CD-collection? I would want  
to find a cd-collection by searching for CD properties like 'musician'.

To my knowledge there are two solutions:

1. Simply adding the CD objects as nested objects to the CD collection.
2. Defining a parent/child mapping with a \_parent type on the CD type

With solution 1 I wouldn't have to touch the CD type but as soon as a CD is  
changing I would have to reindex all CD Collections to show the changes.  
Solution 2 has the benefit of not having to worry about updates on CD  
documents but as soon as I add a new complex category (e.g. called  
book-collection) I'll have to remap the book type and any child categories  
of book (e.g. children-books for lack of a better example 🙂 ).

What would be your suggestions? As far as I know a mapping on e.g.  
CD-collection defining a child type 'CD' isn't possible. Maybe I am missing  
something really obvious but I am a newbie when it comes to search.

Thanks in advance!

Haensel

---

<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:54am UTC](https://discuss.elastic.co/t/best-practises-for-indexing-relationships-between-objects/5342/2 "2017-07-06T03:54:55Z")

</div>


