Rebuilding an index with zero downtime using aliases

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ebaef7c5-fa32-49a9-832e-cc9c6216ed8e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.