由于我要调用多个索引并且必须使用object
类型,因此可以通过索引名称来推断弹性搜索文档的类型。
var indices = Indices.Index(entities);
var search = new SearchRequest(indices)
{
From = page,
Size = pageSize,
Query = fullQuery,
IgnoreUnavailable = true,
};
var response = this.client.Search<object>(search);
是否可以基于某种type / indexName映射从弹性搜索中推断出每个对象的类型?
答案 0 :(得分:0)
也许您可以尝试泛型。
var indices = Indices.Index(entities);
var search = new SearchRequest(indices)
{
From = page,
Size = pageSize,
Query = fullQuery,
IgnoreUnavailable = true,
};
var response = this.client.Search<T>(search);
return response;