Reputation: 2933
In an application I'm querying for 2 documents by Id ("doc1" and "doc2") using an index alias "my_alias"
var multiGetRequest = new MultiGetRequest
{
Documents = new [] {
new MultiGetOperation<Product>("doc1") {Index = "my_alias" },
new MultiGetOperation<Product>("doc2") {Index = "my_alias" }
}
};
var result = client.MultiGet(multiGetRequest);
if (!response.IsValid){
throw new Exception();
}
var documents = result.Documents;
All is fine until someone messes with the alias in Elasticsearch and addes a second index to the alias. The new index also contains documents with ids "doc1" and "doc2".
Using the MultiGet now will lead to
Alias [,y_alias] has more than one indices associated
with it [[demo_index, demo_index2]], can't execute a single index op"
This a expected - but how do I catch the error when using the MultiGet operation?
The code above still executes with out any errors, but now it return no results
Any hints are appreciated!
Upvotes: 1
Views: 164
Reputation: 125518
This is a bug in NEST.
Currently the client doesn't deserialize the error
property on items in the docs
array and additionally, does not take these into account when determining whether the response is valid. I've opened an issue to address this.
Upvotes: 2