What if I've changed mapping for my index and wants to reindex?
I'm currenly using the Java API which does not yet have the reindex functionality, so using bulk would solve my problems. So the solution would look something like this
ref How to reindex in ElasticSearch via Java API
Long time ago
- create index MY_INDEX_1
- create mapping for MY_INDEX_1
- create alias MY_INDEX_1 -> MY_INDEX
- create documents in MY_INDEX
Time to reindex!
- List item
- create index MY_INDEX_2
- create mapping for MY_INDEX_2
- scroll search + bulk all documents from MY_INDEX_1 to MY_INDEX_2
Renaming and deletion of old index
- create alias MY_INDEX_2 -> MY_INDEX
- delete alias MY_INDEX_1 -> MY_INDEX
- delete index MY_INDEX_1
But what happens, while reindexing all documents, a document that was reindexed in the beginning is updated from a user. Or that between reindexing and rename aliases the above happpens?
Possible Solutions ?
- One way would be using external version, such as it does not overwrite an document with an higher version
- Or could it be solved in another way?
- Or between renaming aliases and deleting my_index_1, reindexing all documents that has been indexed since the reindexing? But then still it would be the case that a document has been updated between renaming aliases and second reindexing
- Or should we lock while reindexing? Seems like a bad solution..