# How to re-index Elasticsearch without stale reads?

**URL:** <https://discuss.elastic.co/t/how-to-re-index-elasticsearch-without-stale-reads/254860>\
**Category:** Elasticsearch\
**Created:** [November 10, 2020, 7:50am UTC](https://discuss.elastic.co/t/how-to-re-index-elasticsearch-without-stale-reads/254860 "2020-11-10T07:50:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Callonski](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@Callonski](https://discuss.elastic.co/u/Callonski)\
**Post date:** [November 10, 2020, 7:50am UTC](https://discuss.elastic.co/t/how-to-re-index-elasticsearch-without-stale-reads/254860/1 "2020-11-10T07:50:16Z")

</div>

I have indices with heavy read/write operations. My indices have a read and a write alias. When I need to update the mapping in my indices I go about this process:

1. create a new index with the new mapping,
2. add write-alias to the new index.
3. delete the write-alias to the old index.
4. reindex the data like this

```auto
POST _reindex?wait_for_completion=false
{
"conflicts": "proceed",

"source": {
"index": "old-index"
},
 "dest": {
   "op_type": "create", 
   "index": "new-index"
 }
}

```

1. While reindexing read-alias points to old index while the write-alias points to the new index
2. When the re-indexing is complete, I create a read-alias on the new index and delete the read-alias on the old index.

This process works fine, but there is one caveat. While re-indexing the data is stale to the applications reading, i.e. updates can not be read until I have switched read to the new index.

Since I have quite large indices, the re-indexing takes many hours.

Is there any way to handle re-indexing without reading stale data?

I would of course like to write to two indices at the same time while re-indexing, but as I understand it's not possible.

The only workaround I can think of is to edit on the client-side, so all writes go to both indexes in two separate requests during re-indexing.

Any ideas or comments are much appreciated 🙏

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 10, 2020, 11:40pm UTC](https://discuss.elastic.co/t/how-to-re-index-elasticsearch-without-stale-reads/254860/2 "2020-11-10T23:40:22Z")

</div>

> [@Callonski](#):
>
> The only workaround I can think of is to edit on the client-side, so all writes go to both indexes in two separate requests during re-indexing.

Yep that's a fair approach, and the best that I can think of.

---

<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:** [December 8, 2020, 11:40pm UTC](https://discuss.elastic.co/t/how-to-re-index-elasticsearch-without-stale-reads/254860/3 "2020-12-08T23:40:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
