# Rebuilding an index with zero downtime using aliases

**URL:** <https://discuss.elastic.co/t/rebuilding-an-index-with-zero-downtime-using-aliases/22620>\
**Category:** Elasticsearch\
**Created:** [March 11, 2015, 4:42pm UTC](https://discuss.elastic.co/t/rebuilding-an-index-with-zero-downtime-using-aliases/22620 "2015-03-11T16:42:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![am87](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@am87](https://discuss.elastic.co/u/am87)\
**Post date:** [March 11, 2015, 4:42pm UTC](https://discuss.elastic.co/t/rebuilding-an-index-with-zero-downtime-using-aliases/22620/1 "2015-03-11T16:42:39Z")

</div>

Hey everyone,

I have a question about rebuilding an index. After reading the  
elasticsearch guide and various topics here I've found that the best  
practice for rebuilding an index without any downtime is by using aliases.  
However, there are certain steps and processes around that, which I seek  
advice for. First I'm going to take you through an example scenario, and  
then I'll have some questions.

For example, you have "workshop\_index\_v1", with an alias "workshop". The  
"workshop\_index\_v1" has a type called "guitar" which has three properties  
with the following mapping:

"identifier" : "string"  
"make" : "string"  
"model" : "string"

Lets assume there is a lot of data in workshop\_index\_v1/guitar at the  
moment, which has been populated from a separate database.

Now, I need to modify the mapping, I would like get rid of the "identifier"  
property, so my mapping becomes:

"make" : "string"  
"model" : "string"

As we all know elasticsearch does not allow you to remove a property in the  
mapping directly, you inevitably have to rebuild the index, which is fine  
in my case.

So now a few things came to mind when I though how to do this:

- Create another index "workshop\_index\_v2", populate it with the data in  
"workshop\_index\_v1" using scroll and scan with the bulk API and later  
remove "workshop\_index\_v2" and add "workshop\_index\_v1" to the alias.
- This will not work because the incorrect mapping(or a field value in  
the incorrect mapping) is already present in "workshop\_index\_v1", I do not  
want to copy everything as is.
- Create another index "workshop\_index\_v2", populate it with the data  
from the original source
  - This works

One of the big issues here is, what happens to write requests while the new  
index is being rebuilt.

As you can only write to one index, which one do you write to, the old one  
or the new one, or both?

I feel, that writing to the new one, would work, but any advice regarding  
any of this would be greatly appreciated.

Best regards

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ebaef7c5-fa32-49a9-832e-cc9c6216ed8e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ebaef7c5-fa32-49a9-832e-cc9c6216ed8e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:27am UTC](https://discuss.elastic.co/t/rebuilding-an-index-with-zero-downtime-using-aliases/22620/2 "2017-07-06T00:27:23Z")

</div>


