# Custom routing and multiple indexes where shard distribution is uniform

**URL:** <https://discuss.elastic.co/t/custom-routing-and-multiple-indexes-where-shard-distribution-is-uniform/193144>\
**Category:** Elasticsearch\
**Tags:** ccs-cross-cluster-search\
**Created:** [July 31, 2019, 2:38pm UTC](https://discuss.elastic.co/t/custom-routing-and-multiple-indexes-where-shard-distribution-is-uniform/193144 "2019-07-31T14:38:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![IanRC72](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ianrc72/32/26086_2.png) [@IanRC72](https://discuss.elastic.co/u/IanRC72)\
**Post date:** [July 31, 2019, 2:38pm UTC](https://discuss.elastic.co/t/custom-routing-and-multiple-indexes-where-shard-distribution-is-uniform/193144/1 "2019-07-31T14:38:01Z")

</div>

I have an index `a` with a custom routing field (an int64).

I have a second index `b`, which is a pseudo-child of `a`. It shares the same custom routing value as `a` for "child" documents. In other words, without using a parent-child structure, I can use the routing value to find relevant documents in `a` and then search in `b` where `b.a_id = a._id and b._routing = a._routing`.

Both `a` and `b` have the same number of shards and these divide evenly into the number of nodes (let's say 32 shards each and 2 nodes).

My question is this: will ES put documents on the same node for `a` or `b` where the routing value is the same, or does it automatically offset the root (0) shard number per index?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 31, 2019, 6:15pm UTC](https://discuss.elastic.co/t/custom-routing-and-multiple-indexes-where-shard-distribution-is-uniform/193144/2 "2019-07-31T18:15:17Z")

</div>

Shards can be allocated or moved to any node so are not at all guaranteed to be collocates.

---

<div class="post-metadata">

**Author:** ![IanRC72](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ianrc72/32/26086_2.png) [@IanRC72](https://discuss.elastic.co/u/IanRC72)\
**Post date:** [July 31, 2019, 6:48pm UTC](https://discuss.elastic.co/t/custom-routing-and-multiple-indexes-where-shard-distribution-is-uniform/193144/3 "2019-07-31T18:48:55Z")

</div>

To reword my question, I'm more curious to know if ES will automatically assign hash(key) % node\_count = 0 for all indexes _by default_ to node 0 if all indexes have (shard\_count % node\_count) = 0.

---

<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:** [August 28, 2019, 6:49pm UTC](https://discuss.elastic.co/t/custom-routing-and-multiple-indexes-where-shard-distribution-is-uniform/193144/4 "2019-08-28T18:49:05Z")

</div>

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