ElasticSearch is a great technology for a wide variety of use cases from autocompletion to log management, and is likely to be part of your stack for many complex projects.
In ElasticSearch, you put your data in
indices . An
index is a collection of documents, that shares the same
We have found that
Index management can be hard to manage over time:
During the life of a project, without being managed, an index will surely break .
In order to have the flexibility to change your index
mappings or static
settings whenever you want, you need to be able to create a new index with the same content and the new
settings . Once reindexed, you need to use this new index instead of the original one. Ideally, this should happen with no downtime.
Keeping track of changing indices names at a given moment in your project can be hard to manage. ElasticSearch provides a solution to this with
aliases : you can search and write to aliases like you do with indices. Aliases are just redirects to one or more indices, possibly with some filtering. They also allow you to redirect all of the queries from an index to a new one, with no downtime.
Here are simplified, nominal examples of what you should do to manipulate index-like alias
One of the best ways to allow both machines and humans (for testing) to create indices that work in the long run, is to deploy
index templates prior to any creations or updates with this workflow.
Leaistic is both a
library you can integrate, and a standalone REST
microservice with a nice SwaggerUI . Leaistic provides high-level primitives for creating, updating, and deleting indices, index templates, and aliases working together to help with the problems listed above. It does not cover all ElasticSearch possibilities like
rollover index , multi-indices strategies, etc. If you start a new project with ElasticSearch, it will help you get your indices right. Leaistic tries to be resilient against external changes in parallel with its operations, and has a per-alias locking mechanism to compensate for ElasticSearch’s lack of transactions for these operations. It is committed to providing helpful errors, and to rollback, when necessary, to the best possible state.
There is detailed usage information in the repo . Be sure to also read ‘Why use Leaistic’ and let us know what you think.