# Routing

**URL:** <https://discuss.elastic.co/t/routing/9203>\
**Category:** Elasticsearch\
**Created:** [October 1, 2012, 8:09pm UTC](https://discuss.elastic.co/t/routing/9203 "2012-10-01T20:09:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Douglas\_Ferguson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/douglas_ferguson/32/2121_2.png) [@Douglas\_Ferguson](https://discuss.elastic.co/u/Douglas_Ferguson)\
**Post date:** [October 1, 2012, 8:09pm UTC](https://discuss.elastic.co/t/routing/9203/1 "2012-10-01T20:09:10Z")

</div>

I'm curious about using routing.

Let's assuming I use my user\_id for routing. If I understand it correctly,  
then all documents for that user id  
will be in it's own shard.

I'm not sure how this co-exists with the need to specific the # of shards  
when creating an index.  
Does routing automatically increase the # of shards when it sees a new  
routing id or does it map  
routes into the existing set of shards.

--

---

<div class="post-metadata">

**Author:** ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)\
**Post date:** [October 1, 2012, 8:12pm UTC](https://discuss.elastic.co/t/routing/9203/2 "2012-10-01T20:12:00Z")

</div>

Hello!

Routing doesn't increase the amount of shards and will route you documents to available shards. That means that you can have documents with different user\_id in a single shard, so in addition to routing you should also add filtering for the same user\_id if you wan to get documents for a particular user only.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

I'm curious about using routing.

Let's assuming I use my user\_id for routing. If I understand it correctly, then all documents for that user id

will be in it's own shard.

I'm not sure how this co-exists with the need to specific the # of shards when creating an index.

Does routing automatically increase the # of shards when it sees a new routing id or does it map

routes into the existing set of shards.

--

---

<div class="post-metadata">

**Author:** ![Douglas\_Ferguson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/douglas_ferguson/32/2121_2.png) [@Douglas\_Ferguson](https://discuss.elastic.co/u/Douglas_Ferguson)\
**Post date:** [October 1, 2012, 11:00pm UTC](https://discuss.elastic.co/t/routing/9203/3 "2012-10-01T23:00:13Z")

</div>

So routing is just a way to ensure that the data is always stored in the  
same shard?

But that shard could contain other users as well?

On Monday, October 1, 2012 3:09:10 PM UTC-5, Douglas Ferguson wrote:

> I'm curious about using routing.
> 
> Let's assuming I use my user\_id for routing. If I understand it correctly,  
> then all documents for that user id  
> will be in it's own shard.
> 
> I'm not sure how this co-exists with the need to specific the # of shards  
> when creating an index.  
> Does routing automatically increase the # of shards when it sees a new  
> routing id or does it map  
> routes into the existing set of shards.

--

---

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [October 2, 2012, 1:21am UTC](https://discuss.elastic.co/t/routing/9203/4 "2012-10-02T01:21:31Z")

</div>

Hi,

Yes, sharding means consistent indexing of documents with certain field  
value(s) to a particular shard and, yes, this does not mean that that  
multiple different field values cannot map and be routed to the same shard.

## Otis

Search Analytics - [Cloud Monitoring Tools & Services | Sematext](http://sematext.com/search-analytics/index.html)  
Performance Monitoring - [Sematext Monitoring | Infrastructure Monitoring Service](http://sematext.com/spm/index.html)

On Monday, October 1, 2012 7:00:13 PM UTC-4, Douglas Ferguson wrote:

> So routing is just a way to ensure that the data is always stored in the  
> same shard?
> 
> But that shard could contain other users as well?
> 
> On Monday, October 1, 2012 3:09:10 PM UTC-5, Douglas Ferguson wrote:
> 
> > I'm curious about using routing.
> > 
> > Let's assuming I use my user\_id for routing. If I understand it  
> > correctly, then all documents for that user id  
> > will be in it's own shard.
> > 
> > I'm not sure how this co-exists with the need to specific the # of shards  
> > when creating an index.  
> > Does routing automatically increase the # of shards when it sees a new  
> > routing id or does it map  
> > routes into the existing set of shards.

--

---

<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 6, 2017, 3:10am UTC](https://discuss.elastic.co/t/routing/9203/5 "2017-07-06T03:10:33Z")

</div>


