Best practises for indexing relationships between objects

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 :slight_smile: ).

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