以前在NEST(对于Elasticsearch 1.x)中,在聚合查询之后,我通过遍历所有桶来获得了一些代码并对聚合进行了分组,类似于:
var r = (from SingleBucket items1 in result.Aggregation.Values
select (Bucket) agg1
into items1Aggs
from col1 in items1Aggs.Items.Cast<KeyItem>()
....
select new x {}).ToList();
但似乎现在SingleBucket
必须是SingleBucketAggregate
,但之前使用的Bucket
类现在是一个无法长时间访问的内部BucketAggregateData
类。有没有办法解决这个问题?
正在使用的聚合查询:
var result = _client.Search<MetaStoreEntry>(s => s
.Aggregations(a => a
.Filter("fullGroupBy", k => fad
.Aggregations(e => e
.Terms("col1", t => t
.Field(f => f.col1)
.Aggregations(b => b
.Terms("col2", u => u
.Field(f => f.col2)
...
).Size(int.MaxValue).CollectMode(TermsAggregationCollectMode.DepthFirst)
) ...
);