Get api by id fails when 2 aliases map to same index

Given 2 indexes which both contain the same alias (this is done to reindex without downtime). When searching with the alias, everything still works as expected, yet when I try to retrieve a document by id (eg /books/1) I get an exception. Lo and behold:

curl -XPUT 'http://localhost:9200/my_index_v1'
curl -XPUT 'http://localhost:9200/my_index_v2'

curl -XPOST 'http://localhost:9200/_aliases' -d '
{
    "actions" : [
        { "add" : { "index" : "my_index_v1", "alias" : "my_index" } },
        { "add" : { "index" : "my_index_v2", "alias" : "my_index" } }
    ]
}'

curl -XPOST http://localhost:9200/my_index_v1/books/1 -d '
{
   "author" : "me", "content" : "some"
}'

curl -XPOST http://localhost:9200/my_index_v2/books/2 -d '
{
   "author" : "me", "content" : "more"
}'

curl -XGET http://localhost:9200/my_index/books/_search?q=author=me

This works, hoewever retrieval by id will not:

curl -XGET http://localhost:9200/my_index/books/1


"type": "illegal_argument_exception",
"reason": "Alias [my_index] has more than one indices associated with it [[my_index_v2, my_index_v1]], can't execute a single index op"

Now I could rewrite the getById methods to use a search, but I am wondering if this is the way to go and if this is expected behaviour?

Regards
Ronald

Definitely.

A GET by ID operation should end up to a single shard. The shard is computed based on the ID.
If you have more than one index, elasticsearch can not know in which shard the document is.

If you want to "search" by an ID, then have a look at ids query.

Yes, that makes sense. Thanks for that insight.

Problem is that for a very large and active index, the mapping has to be changed, and I thought that using an alias that points to both the new and the old data set could solve this problem. And it does, but not when using the direct get by id method. So back to the drawing board to create an incremental update probably.

Regards
Ronald