有没有办法用多个聚合编写 Redis.OM 查询?
Is there a way to write Redis.OM query with multiple aggregations?
我正在尝试通过 Redis.OM 在一个调用中为 redis 进行多个聚合。类似于 EF 提供程序的代码:
var efGroup = from props in efquery
group props by props.State into grp
select new
{
PriceSum = grp.Sum(cc => cc.Price),
PriceAvg = grp.Average(c => c.Price),
SizeAvg = grp.Average(c => c.Size)
};
在 redis tutorial page 上有一个如何通过分组进行聚合的示例
var employeeAggregations = provider.AggregationSet<Employee>();
var departments = employeeAggregations.GroupBy(x=>x.RecordShell.Department).Sum(x=>x.RecordShell.Sales);
我试图为此添加额外的调用:
var agr = redisAggr.GroupBy(x => x.RecordShell.State)
.Sum(x => x.RecordShell.Salary)
.Average(x => x.RecordShell.Age)
.ToList();
但这只会抛出 Property 'Age' not present in document or pipeline
。
我也曾尝试对 EF 进行类似的查询,但这只是抛出 Timeout performing UNKNOWN (5000ms)
有没有办法一次性将多个字段设为sums/avg/count?
正如 slorello 所写,它自 0.1.6 以来已修复。
谢谢。
我正在尝试通过 Redis.OM 在一个调用中为 redis 进行多个聚合。类似于 EF 提供程序的代码:
var efGroup = from props in efquery
group props by props.State into grp
select new
{
PriceSum = grp.Sum(cc => cc.Price),
PriceAvg = grp.Average(c => c.Price),
SizeAvg = grp.Average(c => c.Size)
};
在 redis tutorial page 上有一个如何通过分组进行聚合的示例
var employeeAggregations = provider.AggregationSet<Employee>();
var departments = employeeAggregations.GroupBy(x=>x.RecordShell.Department).Sum(x=>x.RecordShell.Sales);
我试图为此添加额外的调用:
var agr = redisAggr.GroupBy(x => x.RecordShell.State)
.Sum(x => x.RecordShell.Salary)
.Average(x => x.RecordShell.Age)
.ToList();
但这只会抛出 Property 'Age' not present in document or pipeline
。
我也曾尝试对 EF 进行类似的查询,但这只是抛出 Timeout performing UNKNOWN (5000ms)
有没有办法一次性将多个字段设为sums/avg/count?
正如 slorello 所写,它自 0.1.6 以来已修复。 谢谢。