Index aliases vs index templates, what to use?

Can anybody tell me the difference between index aliases and index templates. When to use each one, and what are their main advantages? Will it work for an9 whatsapp?

An alias is like a virtual index. It points to one or more concrete indices. And you should always use it as it will help you in case you need to reindex your data using another mapping with no service interruption.

When you create an index you can manually provide mapping and settings for it.
If you have an index template, when you create the index, it will apply the mapping and settings when you create the index.
Index templates are super useful when you are creating a lot of similar indices. Like time based indices.

2 Likes

+Few more words:

An alias is related to the naming one or more indices. Useful for group of indices with similar names: index_YYYYMMDD or index_0001, index_002... You can easily search across multiple indices. The alias doesn't care much what is inside index, I mean the structure. You can use "filter" to set limit which document will accessible.

An template is related how will an index look like. It defines:

  • index settings: number_of_shards, number_of_replicas, ...
  • (field) mappings, which defines fields types: will be string/text, number, ip, boolean, or geo_point or ...

The template can also have alias.

There is more features, however this is enough to have a big picture.

1 Like