# About field routing and integer type

**URL:** <https://discuss.elastic.co/t/about-field-routing-and-integer-type/9298>\
**Category:** Elasticsearch\
**Created:** [October 10, 2012, 1:12am UTC](https://discuss.elastic.co/t/about-field-routing-and-integer-type/9298 "2012-10-10T01:12:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuhan](https://avatars.discourse-cdn.com/v4/letter/y/919ad9/32.png) [@Yuhan](https://discuss.elastic.co/u/Yuhan)\
**Post date:** [October 10, 2012, 1:12am UTC](https://discuss.elastic.co/t/about-field-routing-and-integer-type/9298/1 "2012-10-10T01:12:16Z")

</div>

Hi all,

I just set up one index with field routing with some test data. It stores  
properly with some test data.  
I could see they consistently fall to the same shard with the same field  
value.

However, the type of the field is integer (account\_id), the method  
.setRouting() takes integer as input.  
when I attempt to add .setRouting(""+account\_id) it returned me nothing..  
(but some other random routing  
could reach those shard).

how should I construct the routing correctly from an integer value?.. does  
this mean field routing have to be a string type?

Thank you.

Yuhan

--

---

<div class="post-metadata">

**Author:** ![Yuhan](https://avatars.discourse-cdn.com/v4/letter/y/919ad9/32.png) [@Yuhan](https://discuss.elastic.co/u/Yuhan)\
**Post date:** [October 10, 2012, 1:29am UTC](https://discuss.elastic.co/t/about-field-routing-and-integer-type/9298/2 "2012-10-10T01:29:21Z")

</div>

sorry my bad. it works..

The \_routing field always return a string. not sure what I did wrong last  
time.

Thank you.

Yuhan

On Tue, Oct 9, 2012 at 6:12 PM, Yuhan Zhang [yzhang@onescreen.com](mailto:yzhang@onescreen.com) wrote:

> Hi all,
> 
> I just set up one index with field routing with some test data. It stores  
> properly with some test data.  
> I could see they consistently fall to the same shard with the same field  
> value.
> 
> However, the type of the field is integer (account\_id), the method  
> .setRouting() takes integer as input.  
> when I attempt to add .setRouting(""+account\_id) it returned me nothing..  
> (but some other random routing  
> could reach those shard).
> 
> how should I construct the routing correctly from an integer value?.. does  
> this mean field routing have to be a string type?
> 
> Thank you.
> 
> Yuhan

--  
Yuhan Zhang  
Senior Software Engineer  
OneScreen Inc.  
[yzhang@onescreen.com](mailto:yzhang@onescreen.com) [ehorne@onescreen.com](mailto:ehorne@onescreen.com)  
[www.onescreen.com](http://www.onescreen.com)  
(949) 525-4825 Ext: 177

The information contained in this e-mail is for the exclusive use of the  
intended recipient(s) and may be confidential, proprietary, and/or legally  
privileged. Inadvertent disclosure of this message does not constitute a  
waiver of any privilege. If you receive this message in error, please do  
not directly or indirectly print, copy, retransmit, disseminate, or  
otherwise use the information. In addition, please delete this e-mail and  
all copies and notify the sender.

--

---

<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:09am UTC](https://discuss.elastic.co/t/about-field-routing-and-integer-type/9298/3 "2017-07-06T03:09:28Z")

</div>

Closed on July 6, 2017, 3:09am UTC


