# Shard routing calc

**URL:** <https://discuss.elastic.co/t/shard-routing-calc/112141>\
**Category:** Elasticsearch\
**Created:** [December 18, 2017, 3:48am UTC](https://discuss.elastic.co/t/shard-routing-calc/112141 "2017-12-18T03:48:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![morphers82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morphers82/32/22904_2.png) [@morphers82](https://discuss.elastic.co/u/morphers82)\
**Post date:** [December 18, 2017, 3:48am UTC](https://discuss.elastic.co/t/shard-routing-calc/112141/1 "2017-12-18T03:48:37Z")

</div>

This formula is given for how a doc is routed to a shard.  
shard\_num = hash(\_routing) % num\_primary\_shards

I would like to calculate this to recover a shard that was lost so i can reindex docs that were deleted along with it. I use php to update docs and this index I use my own id's, so I just need to know the hash I can use in php to do this.  
Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 18, 2017, 4:02am UTC](https://discuss.elastic.co/t/shard-routing-calc/112141/2 "2017-12-18T04:02:27Z")

</div>

I would just reindex everything, it's going to be more work the other way.

---

<div class="post-metadata">

**Author:** ![morphers82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morphers82/32/22904_2.png) [@morphers82](https://discuss.elastic.co/u/morphers82)\
**Post date:** [December 18, 2017, 1:24pm UTC](https://discuss.elastic.co/t/shard-routing-calc/112141/3 "2017-12-18T13:24:02Z")

</div>

No, it'll be a lot less work.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 15, 2018, 1:34pm UTC](https://discuss.elastic.co/t/shard-routing-calc/112141/4 "2018-01-15T13:34:25Z")

</div>

Closed on January 15, 2018, 1:34pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
