Parent/Child functionality


(Mike B.) #1

I'm trying to get some more information about Parent Child (_parent) mapping functionality in elasticsearch, I have not been able to find a definitive answer to these questions:

Can parent child mappings be nested to more than two levels?
Can a document have multiple parents of different types?
Can a document have multiple children of different types?

It seems like the answer to all these questions is probably "yes" but I don't want to guess, and was hoping to avoid conducting experiments.

Thanks,
Mike


(Mark Walkom) #2

You can have multiple levels of children, but not multiple parents.


ElasticSearch Nested Objects
(Mike B.) #3

Hi Mark, thanks for your reply. I wanted to be sure I have this right. So, in a relational schema, a table can have multiple foreign keys, which correspond to multiple parents. So ES doesn't support this concept of multiple "FKs" in a document, it would only allow a single "FK"/_parent designation?

Thanks,
Mike


(Imran Siddique) #4

@warkolm - If we have to choose b/w parent-child and nested type where we expect a lot of updates flowing in.
Do you think nested will be better -

  1. Assuming we are ok taking a disk hit, we store _source and do partial update.
  2. Assuming performance of parent-child is not as good as nested.

(Mike B.) #5

I don't understand why a parent/child would be used when nested works. I see _parent as an approach to use when the parent must be maintained as a separate document, probably because of its other relationships outside any single document to which it is being declared as _parent


(Mike B.) #6

An example would be an ES implementation of a relational dimensional star design, where each dimension is a parent to a fact, but dimensions can be associated with more than one fact (table)- each dimension would have multiple children, and each fact would have multiple parents.


(Imran Siddique) #7

Situation where u have updates coming, like children getting added. In case parent-child, a child could be easily added independent of parent getting updated while in nested the document will be updated (delete/add) - OR does ES intelligently adds a new nested (child) document w/o touching parent?


(system) #8