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