# Index routing alias on a field

**URL:** <https://discuss.elastic.co/t/index-routing-alias-on-a-field/15044>\
**Category:** Elasticsearch\
**Created:** [December 29, 2013, 10:08am UTC](https://discuss.elastic.co/t/index-routing-alias-on-a-field/15044 "2013-12-29T10:08:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Han\_JU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han_ju/32/962_2.png) [@Han\_JU](https://discuss.elastic.co/u/Han_JU)\
**Post date:** [December 29, 2013, 10:08am UTC](https://discuss.elastic.co/t/index-routing-alias-on-a-field/15044/1 "2013-12-29T10:08:02Z")

</div>

Hi,

We have put routing on a index, like:

\_routing: {  
path: some\_id  
required: true  
}

We'd like to have also an alias so that the client code is decoupled from  
the index setup. But I don't managed to specify a field for routing, like  
`some_id`, in an alias, other than a specific value.  
I've tried:

{  
"actions" : [  
{  
"add" : {  
"index" : "test",  
"alias" : "test\_alias",  
"routing" : {  
"path": "some\_id"  
}  
}  
}  
]  
}'

And that doesn't seems to work. Is it possible to set a field as the  
routing parameter for an index?  
If I set the routing to some specific value of `some_id`, like 1, 2, it  
works like a charm but it means we need to create an alias for every  
possible value of `some_id`.

Thanks in advance.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/857bfc69-ffa2-4270-bb99-dc377a87de57%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/857bfc69-ffa2-4270-bb99-dc377a87de57%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Boaz\_Leskes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/boaz_leskes/32/723_2.png) [@Boaz\_Leskes](https://discuss.elastic.co/u/Boaz_Leskes)\
**Post date:** [December 30, 2013, 8:05am UTC](https://discuss.elastic.co/t/index-routing-alias-on-a-field/15044/2 "2013-12-30T08:05:49Z")

</div>

HI Han,

Setting a routing path on an alias is not possible. The reason is that an  
alias also has to work for searches/reads where there is no context of a  
document's content to resolve the routing value. Think for example of  
search (/test\_alias/\_search) or document retrieval by ID (GET  
/test\_alias/type/1). Those

Cheers,  
Boaz

On Sunday, December 29, 2013 11:08:02 AM UTC+1, Han JU wrote:

> Hi,
> 
> We have put routing on a index, like:
> 
> \_routing: {  
> path: some\_id  
> required: true  
> }
> 
> We'd like to have also an alias so that the client code is decoupled from  
> the index setup. But I don't managed to specify a field for routing, like  
> `some_id`, in an alias, other than a specific value.  
> I've tried:
> 
> {  
> "actions" : [  
> {  
> "add" : {  
> "index" : "test",  
> "alias" : "test\_alias",  
> "routing" : {  
> "path": "some\_id"  
> }  
> }  
> }  
> ]  
> }'
> 
> And that doesn't seems to work. Is it possible to set a field as the  
> routing parameter for an index?  
> If I set the routing to some specific value of `some_id`, like 1, 2, it  
> works like a charm but it means we need to create an alias for every  
> possible value of `some_id`.
> 
> Thanks in advance.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/367f7961-acc5-4fa5-9092-9654739f0012%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/367f7961-acc5-4fa5-9092-9654739f0012%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Han\_JU](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/han_ju/32/962_2.png) [@Han\_JU](https://discuss.elastic.co/u/Han_JU)\
**Post date:** [December 30, 2013, 9:34am UTC](https://discuss.elastic.co/t/index-routing-alias-on-a-field/15044/3 "2013-12-30T09:34:30Z")

</div>

Thanks Boaz.  
That makes sence. I'll add the routing information in our queries.

在 2013年12月30日星期一UTC+1上午9时05分49秒，Boaz Leskes写道：

> HI Han,
> 
> Setting a routing path on an alias is not possible. The reason is that an  
> alias also has to work for searches/reads where there is no context of a  
> document's content to resolve the routing value. Think for example of  
> search (/test\_alias/\_search) or document retrieval by ID (GET  
> /test\_alias/type/1). Those
> 
> Cheers,  
> Boaz
> 
> On Sunday, December 29, 2013 11:08:02 AM UTC+1, Han JU wrote:
> 
> > Hi,
> > 
> > We have put routing on a index, like:
> > 
> > \_routing: {  
> > path: some\_id  
> > required: true  
> > }
> > 
> > We'd like to have also an alias so that the client code is decoupled from  
> > the index setup. But I don't managed to specify a field for routing, like  
> > `some_id`, in an alias, other than a specific value.  
> > I've tried:
> > 
> > {  
> > "actions" : [  
> > {  
> > "add" : {  
> > "index" : "test",  
> > "alias" : "test\_alias",  
> > "routing" : {  
> > "path": "some\_id"  
> > }  
> > }  
> > }  
> > ]  
> > }'
> > 
> > And that doesn't seems to work. Is it possible to set a field as the  
> > routing parameter for an index?  
> > If I set the routing to some specific value of `some_id`, like 1, 2, it  
> > works like a charm but it means we need to create an alias for every  
> > possible value of `some_id`.
> > 
> > Thanks in advance.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7e516f27-8a96-46a9-98e4-82825cb2e331%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7e516f27-8a96-46a9-98e4-82825cb2e331%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:59am UTC](https://discuss.elastic.co/t/index-routing-alias-on-a-field/15044/4 "2017-07-06T01:59:04Z")

</div>


