# \[SOLVED\] Customing document routing

**URL:** <https://discuss.elastic.co/t/solved-customing-document-routing/54470>\
**Category:** Elasticsearch\
**Created:** [June 30, 2016, 9:49pm UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470 "2016-06-30T21:49:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![axelfelix](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@axelfelix](https://discuss.elastic.co/u/axelfelix)\
**Post date:** [June 30, 2016, 9:49pm UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470/1 "2016-06-30T21:49:59Z")

</div>

Hi all,

Regarding [elasticsearch blog](https://www.elastic.co/blog/customizing-your-document-routing) I can read:

> _"Routing ensures that all documents with the same routing value will locate to the same shard"_

Now in my configuration I have 20 shards and 4 document type. It is possible to route a document type toward 5 shards, a second document type toward another 5 shards, etc ?

Because I don't want to route a document type toward just one shard and get others document in the 19 shards left or inside the first shard, according the blog:

> _"Routing ensures that documents of a particular routing value all go to the same shard…but that doesn’t mean that other documents aren’t routed to the shard too."_

Thanks in advance,  
Alex

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 1, 2016, 5:25am UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470/2 "2016-07-01T05:25:50Z")

</div>

No. That's not possible IMO.  
The routing key is used to compute a single shard number.

You could use routing keys like foo1, foo2, foo3 for all docs of foo type but this is something you have to deal with on a client level.

Why do you have 20 shards BTW?

---

<div class="post-metadata">

**Author:** ![axelfelix](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@axelfelix](https://discuss.elastic.co/u/axelfelix)\
**Post date:** [July 1, 2016, 8:59am UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470/3 "2016-07-01T08:59:22Z")

</div>

Hi,

Thanks for your answer.

I have 20 shards because I have 6 nodes in my cluster, it will be possible to increase the node number to 10.  
So the goal is to have 2 shards per node (2 processes running on each node).

Have a good day,  
Alex

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 1, 2016, 12:20pm UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470/4 "2016-07-01T12:20:48Z")

</div>

what kind of data are you indexing?  
Depending on that you could imagine another way to design your indices.

---

<div class="post-metadata">

**Author:** ![axelfelix](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@axelfelix](https://discuss.elastic.co/u/axelfelix)\
**Post date:** [July 1, 2016, 12:35pm UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470/5 "2016-07-01T12:35:18Z")

</div>

It's logs.

I'm interesting 🙂

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 1, 2016, 4:34pm UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470/6 "2016-07-01T16:34:11Z")

</div>

Logs commonly have timestamp. A good practice is to create rolling indices. One per timeframe you wish:  
day, month, year, 10d... Whatever.

It means that you can easily drop old data with just a `DELETE oldindex` call. You can create an alias on top of them so you will query all the indices as if there was only one.

Well. Then if you feel that you need more horse power, just start new nodes and let elasticsearch do its job.

Have a look at [https://www.elastic.co/guide/en/elasticsearch/guide/current/time-based.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/time-based.html)

---

<div class="post-metadata">

**Author:** ![axelfelix](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@axelfelix](https://discuss.elastic.co/u/axelfelix)\
**Post date:** [July 1, 2016, 6:27pm UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470/7 "2016-07-01T18:27:19Z")

</div>

Hi thanks,

That's already what I did 😉

I have 3 nodes levels:

> - hot
> - cold
> - archive

I route indices between hot and cold nodes and between cold and archive nodes I make a reindex with a lost data and segment optimization.

Have a good day,  
Alex

---

<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:** [July 5, 2017, 10:38pm UTC](https://discuss.elastic.co/t/solved-customing-document-routing/54470/8 "2017-07-05T22:38:53Z")

</div>


