简体   繁体   中英

Elasticsearch parent-child relationship scaling

While going through elasticsearch documentation on Parent-Child relationship I found this line and I am not to sure about it.

the parent document and all of its children must live on the same shard.

Use Case:

  • I have a Elasticsearch index in parent-child relationship with two types company[parent] and employee[child]
  • The records to be indexed are in these pattern 1 parent has more than 100 child.
  • The volume of the index is big so we need to shard them across multiple systems

As per the statement both parent and child as to reside in the same shard since we are sharding across multiple systems is there chance that parent and child may reside in different shard.

if so how to avoid them? if not please explain?

Every document use _routing field that points to some shard. Read more about routing here .

The default value used for _routing is the document's _id or the document's _parent ID, if present.

It means that by default all your child documents will be on the same shard with their parent documents.
Your case is pretty simple, so using defaults there is no chance that parent and child may reside in different shard.

But if relation is grand-parent or even more complex, you need to set routing manually. More details here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM