从NEST的索引名称推断弹性搜索类型

问题描述 投票:0回答:1

由于我正在尝试调用多个索引并且必须使用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映射从弹性搜索中推断出每个对象的类型?

elasticsearch nest
1个回答
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;
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.