# Reindexing while updating documents?

**URL:** <https://discuss.elastic.co/t/reindexing-while-updating-documents/62911>\
**Category:** Elasticsearch\
**Created:** [October 13, 2016, 8:09am UTC](https://discuss.elastic.co/t/reindexing-while-updating-documents/62911 "2016-10-13T08:09:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blommis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/blommis/32/98529_2.png) [@blommis](https://discuss.elastic.co/u/blommis)\
**Post date:** [October 13, 2016, 8:09am UTC](https://discuss.elastic.co/t/reindexing-while-updating-documents/62911/1 "2016-10-13T08:09:09Z")

</div>

Hi,

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

**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!**  
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?

**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..

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:12pm UTC](https://discuss.elastic.co/t/reindexing-while-updating-documents/62911/2 "2017-07-05T22:12:42Z")

</div>


