Can we link documents (parent) to the documents (child)?

I would like to know if two documents can be linked to get the search benefits?

For example:
I have a child document which is formed from parent document. I do not want to copy the complete document metadata to child so that child is searchable by parent information. If there is a way to link documents, that helps to avoid having redundant data.

I am talking in the range of Million documents here. Any information would be helpful.

Thank you

Have a look at Join datatype | Elasticsearch Guide [7.5] | Elastic

Why don't you want to do that?

Because there would be 1000's of child documents for one parent. And replicating all this duplicate data across childs is lot of space. And I am talking about Millions of parent documents and Millions of child documents.

But doing joins has some tradeoff.

My advice:

  • try without join, index some million documents and check if disk usage is actually a problem
  • if it's really a problem, move to parent/child but understand that it will be slower, will complicate your queries and will consume more heap space.
2 Likes

I was also looking for performance impact if we go this way. very helpful information. I will consider your thoughts.

do a virtual join by yourself with a field.
Have the parent hold the data and the child doc contains a field say "parent_id" that holds the "_id" of the parent.
That way you search with the result of the child and get the exact doc (parent) via _id.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.