# Index-Switch

**URL:** <https://discuss.elastic.co/t/index-switch/156683>\
**Category:** Elasticsearch\
**Created:** [November 14, 2018, 1:54pm UTC](https://discuss.elastic.co/t/index-switch/156683 "2018-11-14T13:54:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Animesh\_singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/animesh_singh/32/46768_2.png) [@Animesh\_singh](https://discuss.elastic.co/u/Animesh_singh)\
**Post date:** [November 14, 2018, 1:54pm UTC](https://discuss.elastic.co/t/index-switch/156683/1 "2018-11-14T13:54:31Z")

</div>

Can anyone help me with switching of indexes with reindexing old one without loosing new data that is indexed on old index during the time of reindexing .

---

<div class="post-metadata">

**Author:** ![byronvoorbach](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/byronvoorbach/32/8283_2.png) [@byronvoorbach](https://discuss.elastic.co/u/byronvoorbach)\
**Post date:** [November 14, 2018, 2:22pm UTC](https://discuss.elastic.co/t/index-switch/156683/2 "2018-11-14T14:22:07Z")

</div>

Could you be a bit more elaborate? 🙂

---

<div class="post-metadata">

**Author:** ![Animesh\_singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/animesh_singh/32/46768_2.png) [@Animesh\_singh](https://discuss.elastic.co/u/Animesh_singh)\
**Post date:** [November 15, 2018, 6:55am UTC](https://discuss.elastic.co/t/index-switch/156683/3 "2018-11-15T06:55:54Z")

</div>

ok , let explain the problem  
i have millions of documents that have been indexed are more come every minute and according to need i have to change templates time to time and have to reindex whole lot of documents again , now problem arises when new documents are indexed in old index during the time of re-indexing , that lot is lost .  
How to sync both the index and then discard old one ?  
suggest any solutions?

---

<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 15, 2018, 7:27am UTC](https://discuss.elastic.co/t/index-switch/156683/4 "2018-11-15T07:27:24Z")

</div>

Have a write index and a read index. The write index points to the active index and the read index covers both the active and old index.

Then in your code you will need to use the read index to query, and then deal with any duplicates in queries.

---

<div class="post-metadata">

**Author:** ![Animesh\_singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/animesh_singh/32/46768_2.png) [@Animesh\_singh](https://discuss.elastic.co/u/Animesh_singh)\
**Post date:** [November 15, 2018, 7:31am UTC](https://discuss.elastic.co/t/index-switch/156683/5 "2018-11-15T07:31:13Z")

</div>

Sorry , but i could not get what you are suggesting , please explain more

---

<div class="post-metadata">

**Author:** ![Animesh\_singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/animesh_singh/32/46768_2.png) [@Animesh\_singh](https://discuss.elastic.co/u/Animesh_singh)\
**Post date:** [November 15, 2018, 12:11pm UTC](https://discuss.elastic.co/t/index-switch/156683/6 "2018-11-15T12:11:36Z")

</div>

Yes i got what are you suggesting , but can you tell me how get the timestamp of last update of document so that i can re-index in my new index and then discard the old one

---

<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 15, 2018, 11:55pm UTC](https://discuss.elastic.co/t/index-switch/156683/7 "2018-11-15T23:55:41Z")

</div>

Do you have a timestamp in the document you can use for this?

---

<div class="post-metadata">

**Author:** ![Animesh\_singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/animesh_singh/32/46768_2.png) [@Animesh\_singh](https://discuss.elastic.co/u/Animesh_singh)\
**Post date:** [November 16, 2018, 7:07am UTC](https://discuss.elastic.co/t/index-switch/156683/8 "2018-11-16T07:07:00Z")

</div>

No i don't have time stamp in my ES , i am enquiring is there any timestamp field that is managed my elastic search only because if i give value of timestamp from application , due to network delay values will not be reflected correct and if es server give me i can manage it more efficiently

---

<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 16, 2018, 7:29am UTC](https://discuss.elastic.co/t/index-switch/156683/9 "2018-11-16T07:29:17Z")

</div>

You will need to add that then.

---

<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 14, 2018, 7:34am UTC](https://discuss.elastic.co/t/index-switch/156683/10 "2018-12-14T07:34:42Z")

</div>

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