Skip to content

Index Aliases #88

@kimchy

Description

@kimchy

Allow to define aliases to indices, and have all APIs support that. Here is a simple way to define the alias using the REST API (localhost:9200/_aliases):

{
    actions : [
        { add : { index : "test1", alias : "alias1" } }
    ]
}

In the above, we define an alias1 for index test1. In all operations, we can use alias1 instead of test1. The API also allows to remove an alias from an index, and better yet remove and then add an alias for an index:

{
    actions : [
        { remove : { index : "test1", alias : "alias1" } },
        { add : { index : "test1", alias : "alias2" } }
    ]
}

In the above example, we simple remove alias1 and add alias2 to test1 in a single, atomic operation.

Last, but not least, an alias can be assigned to more than one index. This applies to APIs that accept more than one index, such as search and count. Instead of specifying a list of indices, we can just alias them to the same alias, and use it. For example:

{
    actions : [
        { add : { index : "test1", alias : "alias1" } },
        { add : { index : "test1", alias : "alias2" } }
    ]
}

Ohh, and index aliases can be set when creating an index, here is a YAML example:

index:
    aliases : ["alias1", "alias2"]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions