# Updating documents without affecting search

**URL:** https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318
**Category:** Elasticsearch
**Created:** [February 14, 2019, 2:18am UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318 "2019-02-14T02:18:59Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![vijayaraj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijayaraj/32/108105_2.png) [@vijayaraj](https://discuss.elastic.co/u/vijayaraj)
#### Post date: [February 14, 2019, 2:18am UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/1 "2019-02-14T02:18:59Z")

</div>

Hello Guys,  
I have 500,000 documents in my Index which are currently being consumed by search API.  
out of that there are 100,000 documents that I must update everyday.  
Buy my update shouldnt affect the current searches.  
The previous days document should be replaced with current days's document without any delay  
How to achieve this?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 14, 2019, 3:16am UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/2 "2019-02-14T03:16:10Z")

</div>

Would it be possible to reindex actually all the 500k documents in a new index?  
And use an alias to switch from the old to the new index instantly?

---

<div class="post-metadata">

### Author: ![vijayaraj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijayaraj/32/108105_2.png) [@vijayaraj](https://discuss.elastic.co/u/vijayaraj)
#### Post date: [February 14, 2019, 7:10am UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/3 "2019-02-14T07:10:13Z")

</div>

Well that's the problem, the 500,000 may vary to 10,000,000. And also I might be getting updates like 10 times a day.  
I'm that situation is it a good idea to reindex the entire index each and every time??? Will it be faster.  
Thanks

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 14, 2019, 10:52am UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/4 "2019-02-14T10:52:00Z")

</div>

The only way to switch from a given version to a brand new version of the index in a millisecond is by having 2 indices.

But may be describe your problem. We can think of other solutions.  
Like why on the fly indexing won't work for you.

---

<div class="post-metadata">

### Author: ![vijayaraj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijayaraj/32/108105_2.png) [@vijayaraj](https://discuss.elastic.co/u/vijayaraj)
#### Post date: [February 14, 2019, 11:51am UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/5 "2019-02-14T11:51:21Z")

</div>

Hello,  
My scenario is, I have around 10,000,000 documents in my Index.  
As I receive batch updates which might be around 700,000 documents for a particular advertiser, I wipe off the documents for the particular advertiser which I loaded the previous day and load the fresh feed. I get this kind of updates for various advertisers throughout the day at any point in time.  
In the mean time when I perform the wipe off and reload operation, Any active searches performed on my Elasticsearch database may miss the 700,000 products.  
So I am just wondering if there is any solution to overcome this.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 14, 2019, 12:03pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/6 "2019-02-14T12:03:44Z")

</div>

Why not an index per advertiser?

Or

Can't you just update on the fly the existing documents?

---

<div class="post-metadata">

### Author: ![vijayaraj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijayaraj/32/108105_2.png) [@vijayaraj](https://discuss.elastic.co/u/vijayaraj)
#### Post date: [February 14, 2019, 12:22pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/7 "2019-02-14T12:22:12Z")

</div>

You mean the update query??  
Coz deletion takes longer time like 30 seconds and insertion takes another 30 seconds.  
But my requirement is to achieve zero downtime.

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 14, 2019, 12:44pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/8 "2019-02-14T12:44:59Z")

</div>

You don't need to delete. You just need to index again the new version of the documents.  
Elasticsearch will automatically delete and index in one operation.

---

<div class="post-metadata">

### Author: ![vijayaraj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijayaraj/32/108105_2.png) [@vijayaraj](https://discuss.elastic.co/u/vijayaraj)
#### Post date: [February 14, 2019, 1:01pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/9 "2019-02-14T13:01:17Z")

</div>

Oh, that's beautiful. Thanks dadoonet

---

<div class="post-metadata">

### Author: ![vijayaraj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijayaraj/32/108105_2.png) [@vijayaraj](https://discuss.elastic.co/u/vijayaraj)
#### Post date: [February 14, 2019, 3:48pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/10 "2019-02-14T15:48:19Z")

</div>

I Found something on Elasticsearch Documentation

Setting `version_type` to `external` will cause Elasticsearch to preserve the `version` from the source, create any documents that are missing, and update any documents that have an older version in the destination index than they do in the source index:

But I also want to delete stuffs it it doesn't exist in the source index

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 14, 2019, 6:07pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/11 "2019-02-14T18:07:08Z")

</div>

Then why not this?

> Why not an index per advertiser?

---

<div class="post-metadata">

### Author: ![vijayaraj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vijayaraj/32/108105_2.png) [@vijayaraj](https://discuss.elastic.co/u/vijayaraj)
#### Post date: [February 14, 2019, 8:02pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/12 "2019-02-14T20:02:03Z")

</div>

If i have too many indexes then how do i perform search operation ??  
I also wanna know how to delete while Reindexing..

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 14, 2019, 9:20pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/13 "2019-02-14T21:20:35Z")

</div>

You can search across multiple indices.

About reindexing, if you meant in another index, then you don't have to delete old documents. Just don't copy them.

---

<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: [March 14, 2019, 9:20pm UTC](https://discuss.elastic.co/t/updating-documents-without-affecting-search/168318/14 "2019-03-14T21:20:45Z")

</div>

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