由于我正在尝试调用多个索引并且必须使用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);
是否可以基于某种类型/ indexName映射从弹性搜索中推断出每个对象的类型?
也许您可以尝试泛型。
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;