Home » Posts tagged 'Indexing'

Tag Archives: Indexing

Usage of Index Alias in Elasticsearch

An index alias is another name for an index or group of indices. It can substitute the original index name in any API.

Using index alias you can:

  • Create “views” on a subset of the documents in an index.
  • Group multiple indices under same name (This is helpful if you want to perform a single query on multiple indices at the same time).

Use Case

A possible use case is when your application has to switch from an old index to a new index with zero downtime.

Let’s say you want to re-index an index because of some reasons and you’re not using aliases with your index then you need to update your application to use the new index name.

How this is helpful?

Assume that your application is using the alias instead of an index name.

Let’s create an index:

PUT /myindex

Create its alias:

PUT /myindex/_alias/myalias

Now you’ve decided to reindex your index (maybe you want to change the existing mapping).

Once documents have been reindexed correctly, you can switch your alias to point to the new index.

Note: You need to remove the alias from the old index at the same time as we add it to the new index. You can do it using _aliases endpoint atomically.

Reference : Elasticsearch Definitive Guide