在一个应用程序中,我使用索引别名“my\u alias”按Id(“doc1”和“doc2”)查询2个文档
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;
一切都很好,直到有人在Elasticsearch中弄乱了别名,并为别名添加了第二个索引。新索引还包含ID为“doc1”和“doc2”的文档。
现在使用MultiGet将导致
Alias [,y_alias] has more than one indices associated
with it [[demo_index, demo_index2]], can't execute a single index op"
这是意料之中的,但在使用MultiGet操作时,如何捕捉错误呢?
上面的代码仍然执行,没有任何错误,但现在它返回了
没有结果