Indexing RavenDB-查询enum is属性时未返回结果

Indexing RavenDB-查询enum is属性时未返回结果,indexing,ravendb,Indexing,Ravendb,我有以下索引来记录帖子的浏览量: public class PostsByRequestsIndex : AbstractIndexCreationTask<PostRequest, RequestsGroupResult> { public PostsByRequestsIndex() { Map = posts => posts.Select(r => new { RequestCount = 1,

我有以下索引来记录帖子的浏览量:

public class PostsByRequestsIndex : AbstractIndexCreationTask<PostRequest, RequestsGroupResult>
{
    public PostsByRequestsIndex()
    {
        Map = posts => 
            posts.Select(r => new  { RequestCount = 1, 
            PostIdInternal = r.PostIdInternal,
            PostStatus = LoadDocument<Post>(r.Id).Status.CurrentStatus});

        Reduce = posts => posts.GroupBy(r => r.PostIdInternal).Select(
            x =>  new PostsGroupResult { PostIdInternal = x.Key,          
           RequestCount = x.Sum(s => s.RequestCount) , 
           PostStatus = x.First().PostStatus});

    }
}

public class RequestsGroupResult
{
    public PostStatus.Status PostStatus { get; set; }
    public string PostIdInternal { get; set; }
    public int RequestCount { get; set; }
}
该索引中断了对Post类型文档的查询,因此我添加了另一个索引,对所有帖子进行索引:

public class PostsIndex : AbstractIndexCreationTask<Post>
{
    public PostsIndex()
    {
        Map = Posts => Posts.Select(r => new {
            r.Id , 
            Status_CurrentStatus = r.Status.CurrentStatus, 
            r.Title , 
            r.Comments , 
            r.Content , 
//more properties
            r.Created });
        StoreAllFields(FieldStorage.Yes); 
    }
}
这修复了Post类型文档的现有查询问题

以及以下查询:

Session.Query<RequestsGroupResult, PostsByRequestsIndex>()
           .Where(r => r.PostStatus == PostStatus.Status.Init)
           .OrderByDescending(r => r.RequestCount)
在RavenDB studio中检查索引时,显示索引的PostStatus字段不包含任何值,即使Post文档都正确存储了各自的状态


Post.PostStatus字段应如何编制索引以正确检索其状态?

是否将PostStatus枚举持久化为整数或字符串?该值将持久化为字符串是否与服务器未知的类型有关?使用AbstractDynamicComplationExtension是一种解决方案吗?我一直在尝试设置您的配置以复制该问题,但一直在努力使其无法工作!我做了一些可能不正确的假设。如果删除Where语句并调试结果,那么在监视您认为应该显示的结果时,r.PostStatus==PostStatus.Status.Init吗?如果你改变了把两边都转换成字符串的位置,并对它们进行比较,这会有什么好处吗!。如果您的where语句使用另一个属性来代替实例r.RequestCount>10,它是否有效?删除where条件将导致所有“Status.CurrentStatus”成员设置为默认枚举值。所以问题不正确,是说值加载正确。使用stringcomparison会导致服务器报告它不知道如何在查询中转换为字符串。我在索引中添加了另一个字段,以将状态值存储为字符串。使用Raven Studio检查时,此字段保持为空