protected override void Execute() { ArrayList contextHighlightOffsets = null; string context = (Core.State != CoreState.ShuttingDown) ? ContextCtor.GetContext(TermEntry, Lexemes, out contextHighlightOffsets) : ContextCtor.cFragmentsDelimiter; Core.ResourceAP.QueueJob(JobPriority.Immediate, new SetPropProviderDelegate(PropProvider.SetProp), TermEntry.DocIndex, FullTextIndexer.ContextPropId, context); Core.ResourceAP.QueueJob(JobPriority.Immediate, new SetPropProviderDelegate(PropProvider.SetProp), TermEntry.DocIndex, FullTextIndexer.ContextHighlightPropId, contextHighlightOffsets); }
[Test] public void Context1() { indexer.AddDocumentFragment(10, "Attachment 0\n"); indexer.EndBatchUpdate(); Entry[] result = indexer.ProcessQueryInternal("attachment"); Assert.IsTrue(result.Length == 1); ArrayList contextHighlightData; Hashtable map = new Hashtable(); map[0] = "attachment"; string[] tokens = QueryProcessor.LastSearchLexemes; ContextCtor.GetContext(result[0], tokens, out contextHighlightData); }
[Test] public void TestContextWithQueryTermNearRightEnd() { IResource newRes1 = Core.ResourceStore.NewResource("TestType"); indexer.AddDocumentFragment(newRes1.Id, "word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word21 word31 word41 word51 word61 word71 word81 word91 word101 "); indexer.EndBatchUpdate(); Entry[] result = indexer.ProcessQueryInternal("word7 word31"); Assert.IsTrue(result.Length == 1); ArrayList contextHighlightData; string[] tokens = QueryProcessor.LastSearchLexemes; foreach (string tok in tokens) { Console.Write(tok + "; "); } Console.WriteLine(" "); string context = ContextCtor.GetContext(result[0], tokens, out contextHighlightData); Console.WriteLine(context); }