I have index with (for example) 3 shards with "_routing":{"required" :
true}
I'm using year and month as routing keys. For example: "2012.01",
"2001.08", etc.
Is it possible to ensure, that all routing keys "2012xx" are sent to
shard#1, and "2011xx" sent to shard#2, etc? Or they will be mixed somehow?
What is behaviour of ES when number_of_shards much less than number of
routing keys?
I have 20 shards and 20 routing keys: "2012", "2011", "2010", etc. (no
replicas)
How can i ensure, that each shard relates to only_one routing key? (There
are no shard with two routing keys?).
In order to find which shard a document belongs to Elasticsearch is using
the following formula:
hash(routing) % numberOfShards
where
routing is type id or the routing key if it's explicitly specified
hash() - hash function
numberOfShards - the number of shards in the current index.
In other words, Elasticsearch is trying to distribute records evenly across
all shards and records with the same routing key will go the same shards.
That's pretty much all you can expect.
If you want more control over record distribution I would suggest creating
multiple indices so you could fully control record allocation. By wrapping
all these indices into an alias, you can hide routing logic from the rest
of the application.
On Monday, December 10, 2012 8:03:20 AM UTC-5, Konstantin Nikiforov wrote:
I have index with (for example) 3 shards with "_routing":{"required" :
true}
I'm using year and month as routing keys. For example: "2012.01",
"2001.08", etc.
Is it possible to ensure, that all routing keys "2012xx" are sent to
shard#1, and "2011xx" sent to shard#2, etc? Or they will be mixed somehow?
What is behaviour of ES when number_of_shards much less than number of
routing keys?
I have 20 shards and 20 routing keys: "2012", "2011", "2010", etc. (no
replicas)
How can i ensure, that each shard relates to only_one routing key?
(There are no shard with two routing keys?).
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.