Re-indexing data
Re-indexing data in Elasticsearch is a challenge when you have changed the schema or mappings of the fields. Upon changing the schema, you are either required to re-index all the documents of that field to incorporate mapping changes to previous documents stored, or to not re-index older documents, which will become useless with the change in schema.
Process of re-indexing data:
- Create a new index with the new mappings and settings.
- Take the documents from the old index and index it in a new index.
To minimize the effect and downtime of changing the schema and re-indexing, use the following approach.
Using aliases
Aliases are a powerful feature that can easily re-index the complete index data without any downtime. Alias can be considered as a nickname given to the index name. It can be considered as a symbolic link.
Let us see how to use aliases:
- Create an index with its mapping and settings
- Create an alias to point to the index name
After updating the schema/mappings:
- Create a new...