3
votes

When trying to compare a date property in my MapReduce result in one in my application I get a strange behaviour.

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(),

When queryable.Count() is called an exception is thrown. Looking at the url from the exception it seems like "Date: 2012-08-22T00:00:00.0000000" is generated as the query parameter, and then the RavenDB-client interprets "22T00:" as a new field name in the index.

System.InvalidOperationException was unhandled by user code Message=Url: "/indexes/VisitsByMediaSourceAndVersion?query=Date%253A2012-08->22T00%253A00%253A00.0000000&start=0&pageSize=0&aggregation=None"

Why is this? Is there a work around? Am I the only one with this problem?

I can't recreated this problem in the EmbeddableDocumentStore version of RavenDB, does that make sense? If I remove the date query it returns result, so the index in itself works.

Using RavenDB Client 1.2.0.0 and Server 960.

Grateful for all help!

Full stack trace:

System.InvalidOperationException was unhandled by user code Message=Url: "/indexes/VisitsByMediaSourceAndVersion?query=Date%253A2012-08-22T00%253A00%253A00.0000000&start=0&pageSize=0&aggregation=None"

System.ArgumentException: The field '22T00' is not indexed, cannot query on fields that are not indexed at Raven.Database.Indexing.Index.IndexQueryOperation.AssertQueryDoesNotContainFieldsThatAreNotIndexes() in c:\Builds\RavenDB-Stable\Raven.Database\Indexing\Index.cs:line 819 at Raven.Database.Indexing.Index.IndexQueryOperation.d_2e.MoveNext() in c:\Builds\RavenDB-Stable\Raven.Database\Indexing\Index.cs:line 635 at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection) at Raven.Database.DocumentDatabase.<>c_DisplayClass82.b__78(IStorageActionsAccessor actions) in c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:line 838 at Raven.Storage.Esent.TransactionalStorage.ExecuteBatch(Action1 action) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:line 376 at Raven.Storage.Esent.TransactionalStorage.Batch(Action1 action) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:line 337 at Raven.Database.DocumentDatabase.Query(String index, IndexQuery query) in c:\Builds\RavenDB-Stable\Raven.Database\DocumentDatabase.cs:line 781 at Raven.Database.Server.Responders.Index.PerformQueryAgainstExistingIndex(IHttpContext context, String index, IndexQuery indexQuery, Guid& indexEtag) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs:line 214 at Raven.Database.Server.Responders.Index.ExecuteQuery(IHttpContext context, String index, Guid& indexEtag) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs:line 179 at Raven.Database.Server.Responders.Index.GetIndexQueryRessult(IHttpContext context, String index) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs:line 119 at Raven.Database.Server.Responders.Index.OnGet(IHttpContext context, String index) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs:line 91 at Raven.Database.Server.Responders.Index.Respond(IHttpContext context) in c:\Builds\RavenDB-Stable\Raven.Database\Server\Responders\Index.cs:line 46 at Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx) in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:line 550 at Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx) in c:\Builds\RavenDB-Stable\Raven.Database\Server\HttpServer.cs:line 316

Source=Raven.Client.Lightweight StackTrace: at Raven.Client.Connection.HttpJsonRequest.HandleErrors(WebException e) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 422 at Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func1 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](Func2 operation, String operationUrl, Boolean avoidThrowing, T& result) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ReplicationInformer.cs:line 548 at Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication[T](String method, String 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, Func2 operation) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ServerClient.cs:line 165 at Raven.Client.Connection.ServerClient.Query(String index, IndexQuery query, String[] includes) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ServerClient.cs:line 727 at Raven.Client.Document.AbstractDocumentQuery2.ExecuteActualQuery() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 462 at Raven.Client.Document.AbstractDocumentQuery2.InitSync() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 444 at Raven.Client.Document.AbstractDocumentQuery2.get_QueryResult() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 430 at Raven.Client.Linq.RavenQueryProviderProcessor1.GetQueryResult[TProjection](IDocumentQuery1 finalQuery) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:line 1456 at Raven.Client.Linq.RavenQueryProviderProcessor1.ExecuteQueryTProjection in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:line 1376 at Raven.Client.Linq.RavenQueryProviderProcessor1.Execute(Expression expression) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:line 1359 at Raven.Client.Linq.RavenQueryProvider1.Execute(Expression expression) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProvider.cs:line 138 at Raven.Client.Linq.RavenQueryProvider1.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](IQueryable1 source) at TotallyMoney.CreditCards.Admin.Web.Controllers.DailyReportController.Report(ReportPostModel reportPostModel) in C:\Development\Git\MediaIngenuity\TotallyMoney.CreditCards\TotallyMoney.CreditCards.Admin.Web\Controllers\DailyReportController.cs:line 33 at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.<>c_DisplayClass15.b_12() at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) InnerException:

2
What build are you using for the client? What build are you using for the server?Ayende Rahien
I upgraded to 1.2.2068-Unstable (latest NuGet) upon this error, no change.Molibar
Any idea about what could be the problem?Molibar
Try using a 1.2 server build.Matt Johnson-Pint

2 Answers

2
votes

This exception occurred because you were using a 1.2 (now 2.0) client against a 1.0 server. This is not supported.

You can use an older client with a newer server, but not the other way around.

0
votes

If it is producing the correct date and you don't need the rest of the data afterwards, could you use a substring to pull only the date, or possibly use a GetDate() around the method queryable.Count()?