Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are aliases in elasticsearch for?

I recently started working in a company that uses Elasticsearch. While most of its concepts are somewhat similar to relational databases and I am able to understand them, I still don't quite get the concept of aliases.

I did not find any such question here and the information provided on the Elasticsearch website did not help much either.

Can someone explain what aliases are for and ideally include an example of a situation where they are needed?

like image 597
Jan Pisl Avatar asked Feb 21 '18 13:02

Jan Pisl


1 Answers

aliases are like soft links or shortcuts to actual indexes

the advantage is to be able to have an alias pointing to index1a while building or re-indexing on index2b and the moment of swapping them is atomic thanks to the alias, to which all code should point

Renaming an alias is a simple remove then add operation within the same API. This operation is atomic, no need to worry about a short period of time where the alias does not point to an index:

[EDIT] as pointed out @wholevinski aliases have other functionalities like:

Multiple indices can be specified for an action ...

all the info is in the page you have linked

[EDIT2] more on why the need/benefit of the atomicity

the key being "zero downtime" https://en.wikipedia.org/wiki/Zero_unscheduled_downtime or https://en.wikipedia.org/wiki/High_availability

https://www.elastic.co/guide/en/elasticsearch/guide/current/index-aliases.html

We will talk more about the other uses for aliases later in the book. For now we will explain how to use them to switch from an old index to a new index with zero downtime.

like image 155
arhak Avatar answered Nov 16 '22 03:11

arhak