I have an index with 3 primary and 1 replicas,total 6 shards for an index.
I sent 5 messages to Elasticsearch cluster and these messages is distributed among 5 different shards.
As a client i am curious how a client can retrieve particular message using document id.
But how this document is routed.When i sent GET request how my client know that document id is stored in this shards and nodes.
The shard id is computed from the document id.
It's basically "a modulo the number of shards".
are you saying this formula
shard_id=hash(document_id) % no_of_shards
Yes. See _routing field | Elasticsearch Guide [8.1] | Elastic
routing_factor = num_routing_shards / num_primary_shards
shard_num = (hash(_routing) % num_routing_shards) / routing_factor
_routing is provided, then the
_id is used.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.