Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliases: allow to specify routing value for an alias #1025

Closed
imotov opened this issue Jun 13, 2011 · 0 comments
Closed

Aliases: allow to specify routing value for an alias #1025

imotov opened this issue Jun 13, 2011 · 0 comments

Comments

@imotov
Copy link
Contributor

imotov commented Jun 13, 2011

It’s now possible to associate routing values with aliases. This feature can be used together with filtering aliases in order to avoid unnecessary shard operations.

The following command creates a new alias "alias1" that points to index "test". After "alias1" is created, all operations with this alias are automatically modified to use value "1" for routing.

$ curl -XPOST 'http://localhost:9200/_aliases' -d '
{
    "actions" : [
        {
            "add" : {
                 "index" : "test",
                 "alias" : "alias1",
                 "routing" : "1"
            }
        }
    ]
}'

It’s also possible to specify different routing values for searching and indexing operations:

$ curl -XPOST 'http://localhost:9200/_aliases' -d '
{
    "actions" : [
        {
            "add" : {
                 "index" : "test",
                 "alias" : "alias2",
                 "search-routing" : "1,2",
                 "index-routing" : "2"
            }
        }
    ]
}'

As shown in the example above, search routing may contain several values separated by comma. Index routing can contain only a single value.

If an operation that uses routing alias also has a routing parameter, an intersection of both alias routing and routing specified in the parameter is used. For example the following command will use "2" as a routing value:

$ curl -XGET 'http://localhost:9200/alias2/_search?q=user:kimchy&routing=2,3'
@kimchy kimchy closed this as completed Jun 13, 2011
williamrandolph pushed a commit to williamrandolph/elasticsearch that referenced this issue Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants