Super confused about multiple indices with a single alias

(Patrick Collins) #1

I have read the documentation that says:

An alias can point to multiple indices, so we need to remove the alias from the old index at the same time as we add it to the new index. The change needs to be atomic, which means that we must use the _aliases endpoint:

say I have an index "stuff_v1", with an alias "stuff".

And also say that stuff_v1 has an incorrect type for a column in the mapping and I need to fix that.

I was under the impression that I could:

  1. update my mapping with the correct type.
  2. create a new index "stuff_v2" with the new mapping
  3. set the alias "stuff" on it so both "stuff_v1" and "stuff_v2" have the same alias
  4. scan & scroll stuff_v1 into stuff_v2 -- meanwhile because they both share the same alias, indexing a record will work and go into both indices.

... That's what I thought was how all this works...

However, when I tried to do this, I get:

ElasticsearchIllegalArgumentException[Alias [stuff_alias] has more than one indices associated with it [[stuff_v1, stuff_v2]], can't execute a single index op]

so................................... I guess I totally don't understand how this zero downtime stuff is really supposed to work.


(Camilo Sierra) #2

the alias you can used to read, when you index use the real index name!

you search with "stuff" and index in "stuff_v2"

(Patrick Collins) #3

But the whole point is, during a scan & scroll on a huge document that takes hours, I want both stuff_v1 and stuff_v2 to be indexed at the same time so that when I am done with the scan & scroll, I don't have any missing records. The goal is to be able to remove the alias on stuff_v1.

(Mark Walkom) #4

Except when you are querying both you may get duplicate records, how will you deal with that?

(system) #5