我有一个map / reduce索引,如下所示(在服务器上定义)。
地图:
from request in docs.Master_Requests
select new
{
DocumentID = Guid.NewGuid(),
Year = request.Timestamp.Year,
Month = request.Timestamp.Month,
Day = request.Timestamp.Day,
Hour = request.Timestamp.Hour,
Minute = request.Timestamp.Minute,
RequestBytes = request.RequestBytes,
ResponseBytes = request.ResponseBytes,
TotalRequests = 1
}
减少
from result in results
group result by new { result.Year, result.Month, result.Day, result.Hour, result.Minute }
into g
select new
{
DocumentID = Guid.NewGuid(),
Year = g.Key.Year,
Month = g.Key.Month,
Day = g.Key.Day,
Hour = g.Key.Hour,
Minute = g.Key.Minute,
RequestBytes = g.Sum(r => r.RequestBytes),
ResponseBytes = g.Sum(r => r.ResponseBytes),
TotalRequests = g.Sum(r => r.TotalRequests)
}
我正在尝试查询map / reduce索引的结果,如下所示:
session.Query<UsageAggregate>("RequestAggregateByMinute", true)
.Where(a => a.TotalRequests >= 1);
然而,当有很多结果(如工作室中所示)的TotalRequests属性大于1时,我得不到任何结果。当我没有包含where谓词时我得到结果我也得到结果我过滤除聚合属性之外的任何其他属性(RequestBytes,ResponseBytes和TotalRequests)。
有人可以帮我理解我做错了吗?
答案 0 :(得分:1)
好的,我明白了。无论出于何种原因,我需要像这样抛出Sum()的结果。一旦将动态编译发送到raven服务器,这必须与动态编译有关。
from result in results
group result by new { result.Year, result.Month, result.Day, result.Hour, result.Minute }
into g
select new
{
DocumentID = Guid.NewGuid(),
Year = g.Key.Year,
Month = g.Key.Month,
Day = g.Key.Day,
Hour = g.Key.Hour,
Minute = g.Key.Minute,
RequestBytes = (Int32)g.Sum(r => r.RequestBytes),
ResponseBytes = (Int32)g.Sum(r => r.ResponseBytes),
TotalRequests = (Int32)g.Sum(r => r.TotalRequests)
}