Created
December 9, 2013 10:44
-
-
Save andreasohlund/7870379 to your computer and use it in GitHub Desktop.
Issue with free text search on multi map reduce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: | |
| public class MessagesViewIndex : AbstractMultiMapIndexCreationTask<MessagesView> | |
| { | |
| public MessagesViewIndex() | |
| { | |
| AddMap<AuditMessage>(messages => messages.Select(message => new | |
| { | |
| Id = message.Id, | |
| MessageId = message.MessageId, | |
| MessageType = message.MessageType, | |
| Status = MessageStatus.Successful, | |
| ProcessedAt = message.ProcessedAt, | |
| ReceivingEndpointName = message.ReceivingEndpoint.Name, | |
| ConversationId = message.ConversationId, | |
| TimeSent = message.TimeSent, | |
| Query = new object[] | |
| { | |
| message.MessageType, | |
| message.ReceivingEndpoint.Name | |
| } | |
| })); | |
| AddMap<FailedMessage>(messages => messages.Select(message => new | |
| { | |
| Id = message.Id, | |
| MessageId = message.MessageId, | |
| MessageType = message.ProcessingAttempts.Last().Message.MessageType, | |
| message.Status, | |
| ProcessedAt = message.ProcessingAttempts.Last().FailureDetails.TimeOfFailure, | |
| ReceivingEndpointName = message.ProcessingAttempts.Last().Message.ReceivingEndpoint.Name, | |
| ConversationId = message.ProcessingAttempts.Last().Message.ConversationId, | |
| TimeSent = message.ProcessingAttempts.Last().Message.TimeSent, | |
| Query = new object[] | |
| { | |
| message.ProcessingAttempts.Last().Message.MessageType, | |
| message.ProcessingAttempts.Last().Message.ReceivingEndpoint.Name | |
| } | |
| })); | |
| Reduce = results => from message in results | |
| group message by message.Id | |
| into g | |
| select new MessagesView | |
| { | |
| Id = g.Key, | |
| MessageId = g.OrderByDescending(m => m.ProcessedAt).First().MessageId, | |
| MessageType = g.OrderByDescending(m => m.ProcessedAt).First().MessageType, | |
| Status = g.OrderByDescending(m => m.ProcessedAt).First().Status, | |
| ProcessedAt = g.OrderByDescending(m => m.ProcessedAt).First().ProcessedAt, | |
| ReceivingEndpointName = g.OrderByDescending(m => m.ProcessedAt).First().ReceivingEndpointName, | |
| ConversationId = g.OrderByDescending(m => m.ProcessedAt).First().ConversationId, | |
| TimeSent = g.OrderByDescending(m => m.ProcessedAt).First().TimeSent, | |
| Query = g.OrderByDescending(m => m.ProcessedAt).First().Query | |
| }; | |
| Index(x => x.Query, FieldIndexing.Analyzed); | |
| Index(x => x.ReceivingEndpointName, FieldIndexing.Default); | |
| Index(x => x.CriticalTime, FieldIndexing.Default); | |
| Index(x => x.ProcessingTime, FieldIndexing.Default); | |
| Sort(x => x.CriticalTime, SortOptions.Long); | |
| Sort(x => x.ProcessingTime, SortOptions.Long); | |
| Analyze(x => x.Query, typeof(StandardAnalyzer).AssemblyQualifiedName); | |
| } | |
| } | |
| Raven.Imports.Newtonsoft.Json.JsonSerializationException was unhandled by user code | |
| HResult=-2146233088 | |
| Message=Could not read value for property: Query | |
| Source=Raven.Abstractions | |
| StackTrace: | |
| at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) in c:\Builds\RavenDB-Stable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 1602 | |
| at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) in c:\Builds\RavenDB-Stable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 368 | |
| at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) in c:\Builds\RavenDB-Stable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 238 | |
| at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) in c:\Builds\RavenDB-Stable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 164 | |
| at Raven.Imports.Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) in c:\Builds\RavenDB-Stable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonSerializer.cs:line 565 | |
| at Raven.Imports.Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) in c:\Builds\RavenDB-Stable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonSerializer.cs:line 531 | |
| at Raven.Client.Document.SessionOperations.QueryOperation.DeserializedResult[T](RavenJObject result) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\SessionOperations\QueryOperation.cs:line 229 | |
| at Raven.Client.Document.SessionOperations.QueryOperation.Deserialize[T](RavenJObject result) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\SessionOperations\QueryOperation.cs:line 193 | |
| at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext() | |
| at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) | |
| at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) | |
| at Raven.Client.Document.SessionOperations.QueryOperation.Complete[T]() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\SessionOperations\QueryOperation.cs:line 143 | |
| at Raven.Client.Document.AbstractDocumentQuery`2.GetEnumerator() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 892 | |
| at Raven.Client.Linq.RavenQueryInspector`1.GetEnumerator() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryInspector.cs:line 106 | |
| at System.Linq.Buffer`1..ctor(IEnumerable`1 source) | |
| at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) | |
| at ServiceControl.CompositeViews.GetMessages.<.ctor>b__3(Object parameters) in c:\dev\particular\ServiceControl\src\ServiceControl\CompositeViews\GetMessages.cs:line 19 | |
| at CallSite.Target(Closure , CallSite , Func`2 , Object ) | |
| at Nancy.Routing.Route.<>c__DisplayClass4.<Wrap>b__3(Object parameters, CancellationToken context) | |
| InnerException: Raven.Imports.Newtonsoft.Json.JsonReaderException | |
| HResult=-2146233088 | |
| Message=Error reading string. Unexpected token: StartArray. | |
| Source=Raven.Abstractions | |
| LineNumber=0 | |
| LinePosition=0 | |
| StackTrace: | |
| at Raven.Json.Linq.RavenJTokenReader.ReadAsString() in c:\Builds\RavenDB-Stable\Raven.Abstractions\Json\Linq\RavenJTokenReader.cs:line 262 | |
| at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter) in c:\Builds\RavenDB-Stable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 1486 | |
| at Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) in c:\Builds\RavenDB-Stable\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 1588 | |
| InnerException: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment