Elasticsearch how to figure out the shard number with the specified routing?

eg: I have a index with 5 primary shard, when I query/insert a document with routing. How can I figure out the shard number? According to the document the formula is: shard_num = hash(_routing) % num_primary_shards.Certainly, I can read the source code of the hash function, but I want to know there is any plugins or any easy way to figure out the shard number when I specify a routing.
THX in advance.

I don't know of any plugins at the top of my head.

May I ask what's your use case for needing to figure this out?

Isabel

Thanks for your reply.
I have some data, a hundred million entries everyday. I pan to store them in ES with the routing(the date of day, like 20160917).So I want to figure out how many shards I need to set for the index of month and guarantee there is no unused shards.Of course, the empty shard not affect any stuff, and I am curious about it, besides I am a OCD:joy:.
Maybe, I have to read the fucking source code finally.

Have you considered using time-based indices?

1 Like

THX guy.
I have already done so.