我在弹性查询中得到以下结果:
"Results" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "73c47133-8656-45e7-9499-14f52df07b70",
"doc_count" : 1,
"foo" : {
"doc_count" : 40,
"bar" : {
"doc_count" : 1,
"customscore" : {
"value" : 10.496919917864476
}
}
}
}
]
我正试图得到一个匿名对象的列表 key
字段作为键 customscore
字段作为值。
无论我尝试什么,我似乎都无法在访问 customscore
价值观。显然,我是世界上第一个将嵌套聚合与嵌套库结合使用的人。不是这样,就是文件资料非常缺乏。我很容易够到水桶:
response?.Aggregations.Terms("Results").Buckets;
但我不知道该怎么处理这个东西。 Buckets
包含多个对象,我假设可以通过执行以下操作来导航这些对象:
bucketObject["foo"]["bar"]["customscore"]
但显然不是。我找到了用于循环的解决方案,使用长linq查询的解决方案,而且所有这些解决方案似乎都会返回 null
为了我。我错过了什么?
1条答案
按热度按时间k97glaaz1#
假设下面的查询与问题中的回答相匹配
获取匿名类型的集合