【问题标题】:C# elasticsearch infer document types on multiple index queriesC# elasticsearch 在多个索引查询上推断文档类型
【发布时间】:2020-11-20 11:17:24
【问题描述】:

我正在对several indices 执行搜索查询,因此结果列表中可能有多种数据类型。

(我使用 C#.NEST 库 来获取结果) 示例:

var queryResult = await _elasticClient.SearchAsync<object>(q => q
                .Query(s => s
                     /// ... some query logic doesn't really matter
                    )
                ).Index("index-name-1,index-name-2,index-name-3")

结果集可能是这样的:

[
 {
  "LastName": 0,
  "listType": [1,2,3],
  "Name": "alex"
 },
 {
  "amount": 5,
  "amountType": "usd"
 }
...
]

queryResult.Documents 我以Dictionary&lt;string,string&gt; 类型接收所有这些数据,但我想根据各种POCO (普通旧C# 对象) 对象接收它们到他们的 json 类型。基本上我需要 .Nest 来推断不同文档的索引并将它们解析为根据 POCO 对象。

有没有办法通过 .Nest 本身来确定索引类型,或者我可以使用一些 json 解析库来代替 Newtonsoft.Json

【问题讨论】:

标签: c# .net elasticsearch nest


【解决方案1】:
猜你喜欢
  • 2018-05-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-10
  • 2016-01-28
  • 2019-12-25
  • 1970-01-01
相关资源
最近更新 更多