当尝试在我的应用程序中比较 MapReduce 中的日期属性时,我得到一个奇怪的行为。
var queryDate = DateTime.Now.Date;
IQueryable<VisitsByMediaSourceAndVersion.MapReduceResult> queryable =
_documentSession
.Query<MyIndex.MapReduceResult>(MyIndex.INDEX_NAME)
.Where(mapReduceResult => mapReduceResult.Date == queryDate);
var count = queryable.Count(),
调用 queryable.Count() 时会引发异常。从异常中查看 url 似乎“日期:2012-08-22T00:00:00.0000000”作为查询参数生成,然后 RavenDB 客户端将“22T00:”解释为索引中的新字段名称。
System.InvalidOperationException 未被用户代码 Message=Url 处理:“/indexes/VisitsByMediaSourceAndVersion?query=Date%253A2012-08->22T00%253A00%253A00.0000000&start=0&pageSize=0&aggregation=None”
为什么是这样?有解决办法吗?我是唯一一个有这个问题的人吗?
我无法在 RavenDB 的 EmbeddableDocumentStore 版本中重现这个问题,这有意义吗?如果我删除它返回结果的日期查询,那么索引本身就可以工作。
使用 RavenDB 客户端 1.2.0.0 和服务器 960。
感谢所有帮助!
完整的堆栈跟踪:
System.InvalidOperationException 未被用户代码 Message=Url 处理:“/indexes/VisitsByMediaSourceAndVersion?query=Date%253A2012-08-22T00%253A00%253A00.0000000&start=0&pageSize=0&aggregation=None”
System.ArgumentException:字段“22T00”未编入索引,无法查询在 c:\Builds\RavenDB-Stable\Raven.Database\Indexing 中的 Raven.Database.Indexing.Index.IndexQueryOperation.AssertQueryDoesNotContainFieldsThatAreNotIndexes() 中未编入索引的字段\Index.cs:Raven.Database.Indexing.Index.IndexQueryOperation.d_ 2e.MoveNext() 中的第 819 行:\Builds\RavenDB-Stable\Raven.Database\Indexing\Index.cs:System.Linq 中的第 635 行.Enumerable.WhereSelectEnumerableIterator 2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext() at System.Collections.Generic.List 1.InsertRange(Int32 index, IEnumerable
1 collection) at Raven.Database.DocumentDatabase.<>c _DisplayClass82.b__78(IStorageActionsAccessor actions) in c:\Builds\RavenDB-Stable\Raven.Database \DocumentDatabase.cs:Raven.Storage.Esent.TransactionalStorage.ExecuteBatch 的第 838 行(操作1 action) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:line 376
at Raven.Storage.Esent.TransactionalStorage.Batch(Action
1 个操作)在 c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:第 337 行,位于 c:\Builds\RavenDB-Stable\ 中 Raven.Database.DocumentDatabase.Query(字符串索引,IndexQuery 查询) Raven.Database\DocumentDatabase.cs:Raven.Database.Server.Responders.Index.PerformQueryAgainstExistingIndex 的第 781 行(IHttpContext 上下文,字符串索引,IndexQuery indexQuery,Guid& indexEtag)在 c:\Builds\RavenDB-Stable\Raven.Database\Server \Responders\Index.cs:Raven.Database.Server.Responders.Index.ExecuteQuery(IHttpContext context, String index, Guid& indexEtag) 中的第 214 行 c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs 中 Raven.Database.Server.Responders.Index.GetIndexQueryRessult(IHttpContext 上下文,字符串索引)的第 179 行:c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs 中 Raven.Database.Server.Responders.Index.OnGet(IHttpContext context, String index) 的第 119 行:Raven.Database 的第 91 行。 c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs 中的 Server.Responders.Index.Respond(IHttpContext context):Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) 中的第 46 行c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs: 第 550 行位于 c:\Builds\RavenDB-Stable\Raven.Database\Server 中 Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) \HttpServer.cs:第 316 行\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs: 第 46 行 Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) 在 c:\Builds\RavenDB-Stable\Raven.Database\Server \HttpServer.cs:Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) 中的第 550 行:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:第 316 行\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs: 第 46 行 Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) 在 c:\Builds\RavenDB-Stable\Raven.Database\Server \HttpServer.cs:Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) 中的第 550 行:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:第 316 行
Source=Raven.Client.Lightweight StackTrace:在 c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 中的 Raven.Client.Connection.HttpJsonRequest.HandleErrors(WebException e) 1 getResponse) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 292
at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 202
at Raven.Client.Connection.ServerClient.DirectQuery(String index, IndexQuery query, String operationUrl, String[] includes) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ServerClient.cs:line 745
at Raven.Client.Connection.ServerClient.<>c__DisplayClass43.<Query>b__42(String u) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ServerClient.cs:line 727
at Raven.Client.Connection.ReplicationInformer.TryOperation[T](Func
c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ReplicationInformer.cs中 Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func 2 操作,字符串 operationUrl,布尔避免投掷,T& 结果)的 422 :Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication[T] 的第 548 行(字符串方法,字符串 primaryUrl,Int32 currentRequest,Int32 currentReadStripingBase,Func2 operation) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ReplicationInformer.cs:line 520
at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String method, Func
2 操作)在 c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ServerClient.cs:Raven.Client.Connection.ServerClient.Query 的第 165 行(字符串索引,IndexQuery 查询,字符串 [ ] 包括)在 c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ServerClient.cs:line 727 at Raven.Client.Document.AbstractDocumentQuery 2.ExecuteActualQuery() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 462
at Raven.Client.Document.AbstractDocumentQuery
2.InitSync() 在 c:\Builds\ RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:Raven.Client.Document.AbstractDocumentQuery 2.get_QueryResult() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 430
at Raven.Client.Linq.RavenQueryProviderProcessor
1.GetQueryResult[TProjection] 的第 444 行(1 finalQuery) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:line 1456
at Raven.Client.Linq.RavenQueryProviderProcessor
c:\Builds\RavenDB-Unstable 中的 IDocumentQuery 1.ExecuteQueryTProjection -v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:Raven.Client.Linq.RavenQueryProviderProcessor 的第 1376 行1.Execute(Expression expression) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:line 1359
at Raven.Client.Linq.RavenQueryProvider
1.Execute(Expression expression) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProvider.cs:line 138 at Raven.Client.Linq.RavenQueryProvider 1.System.Linq.IQueryProvider.Execute[S](Expression expression) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProvider.cs:line 183
at System.Linq.Queryable.Count[TSource](IQueryable
1 source) at TotallyMoney.CreditCards .Admin.Web.Controllers.DailyReportController.Report(ReportPostModel reportPostModel) 在 C:\Development\Git\MediaIngenuity\TotallyMoney.CreditCards\TotallyMoney.CreditCards.Admin.Web\Controllers\DailyReportController.cs: lambda_method 的第 33 行(闭包,ControllerBase , Object[] ) 在 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase 控制器, Object[] 参数) 在 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary 2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 参数) 在 System.Web.Mvc.ControllerActionInvoker .<>c_ DisplayClass15.b_12() 在 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter 过滤器,ActionExecutingContext preContext,Func`1 延续)InnerException: