Aliases

An alias can give you added flexibility over the content that is being searched. However, this comes at the cost of added complexity from having to maintain the alias.

An example usage for an alias could be the following. Imagine one day you are having a promotion for a new selection of products. You could choose to promote those products against a selection of other products. One way to do this is to re-associate the alias to a prepared index of those products and the associated items:

curl -XPOST localhost:9200/_aliases -d '
{
    "actions": [
        { "add" :   { "alias" : "related", "index": "promotion-2013-12-25"   } },
        { "remove": { "alias" : "related", "index": "relateditems-2013-12-23"} },
        { "remove": { "alias" : "related", "index": "relateditems-2013-12-24"} }
    ]
}'

The above removes the existing mappings and creates the new mapping. This can be done a runtime, without starting either elasticsearch or the searching application. However, the downside here is the maintenance of the alias.

The alias cannot use a wildcard, and it needs to point to a valid index that exists. Therefore, a maintenance script needs to create that would periodically run to update the alias mapping to point to new indexes.

Unfortunately at the moment support for assigning index alias’s at index creation time does not currently exist (https://github.com/elasticsearch/elasticsearch/pull/2739 and https://github.com/elasticsearch/elasticsearch/issues/4920).

For more information about index alias in elasticsearch please read:

http://www.elasticsearch.org/blog/changing-mapping-with-zero-downtime/