openannotation/annotator-store — pull request #93 by Treora (2014-08-20 06:49:42+00:00)
Title: [WIP] Create reindex.py, add warning on mapping conflict

A helper script to easily reindex the Elasticsearch database after an incompatible change in the mapping.
It appeared to me that indexes are stubborn things that do not allow to be renamed. To be able to keep using the same index name with a new mapping, the best solution seems to be to migrate the documents to a new index with a new name, remove the old index, and then alias the new index with the name of the old index.
In general, it seems better to always use aliases that point to some arbitrarily named real index, to retain naming flexibility.

As an example, let's say our index was always called `annotator`. When running this script, it will create an indexer called `annotator_real` (but this could be any arbitrary name), move the data there, and give it the alias `annotator`.
On subsequent reindexations (sp?), the data would move to an index `annotator_real1`, and the `annotator` alias would be updated accordingly.