我需要获取特定集合中的文档计数:
现有索引 Raven/DocumentCollections 存储集合的计数和名称,与属于集合的实际文档配对。如果可能的话,我想从这个索引中获取计数。
这是 Raven/DocumentCollections 索引的 Map-Reduce:
from doc in docs
let Name = doc["@metadata"]["Raven-Entity-Name"]
where Name != null
select new { Name , Count = 1}
from result in results
group result by result.Name into g
select new { Name = g.Key, Count = g.Sum(x=>x.Count) }
在旁注中,var Count = DocumentSession.Query<Post>().Count();
始终返回 0 作为我的结果,即使我的数据库中显然有 500 个奇怪的文档,其中至少 50 个在其元数据“Raven-Entity-Name”中作为“帖子”。我完全不知道为什么这个 Count 查询一直返回 0 作为答案 - Raven 日志在 Count 完成时显示这一点
Request # 106: GET - 0 ms - TestStore - 200 - /indexes/dynamic/Posts?query=&start=0&pageSize=1&aggregation=None