The6thSense
The6thSense

Reputation: 8335

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:

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?

Upvotes: 1

Views: 319

Answers (1)

Taras Kohut
Taras Kohut

Reputation: 2555

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

Upvotes: 2

Related Questions