public void TestDiscreteMultiValueHighlighting() { makeIndexShortMV(); FieldQuery fq = new FieldQuery(tq("d"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder(); sfb.IsDiscreteMultiValueHighlighting = (true); assertEquals("<b>d</b> e", sfb.CreateFragment(reader, 0, F, ffl)); make1dmfIndex("some text to highlight", "highlight other text"); fq = new FieldQuery(tq("text"), true, true); stack = new FieldTermStack(reader, 0, F, fq); fpl = new FieldPhraseList(stack, fq); sflb = new SimpleFragListBuilder(); ffl = sflb.CreateFieldFragList(fpl, 32); String[] result = sfb.CreateFragments(reader, 0, F, ffl, 3); assertEquals(2, result.Length); assertEquals("some <b>text</b> to highlight", result[0]); assertEquals("highlight other <b>text</b>", result[1]); fq = new FieldQuery(tq("highlight"), true, true); stack = new FieldTermStack(reader, 0, F, fq); fpl = new FieldPhraseList(stack, fq); sflb = new SimpleFragListBuilder(); ffl = sflb.CreateFieldFragList(fpl, 32); result = sfb.CreateFragments(reader, 0, F, ffl, 3); assertEquals(2, result.Length); assertEquals("text to <b>highlight</b>", result[0]); assertEquals("<b>highlight</b> other text", result[1]); }
public void TestNullFieldFragList() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "b c d"), 100); assertEquals(0, ffl.FragInfos.size()); }
public void Test1TermIndex() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a"), 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1)))/1.0(0,100)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void TestSmallerFragSizeThanTermQuery() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "abcdefghijklmnopqrs")), "abcdefghijklmnopqrs"), sflb.minFragCharSize); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(abcdefghijklmnopqrs((0,19)))/1.0(0,19)", ffl.FragInfos[0].toString()); }
public void TestSmallerFragSizeThanTermQuery() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "abcdefghijklmnopqrs")), "abcdefghijklmnopqrs"), sflb.minFragCharSize); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(abcdefghijklmnopqrs((0,19)))/1.0(0,19)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void Test1TermIndex() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a"), 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1)))/1.0(0,100)", ffl.FragInfos[0].toString()); }
public void TestTooSmallFragSize() { try { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "b c d"), sflb.minFragCharSize - 1); fail("IllegalArgumentException must be thrown"); } catch (ArgumentOutOfRangeException) // LUCENENET specific - changed from IllegalArgumentException to ArgumentOutOfRangeException (.NET convention) { } }
public void Test1PhraseLongMVB() { makeIndexLongMVB(); FieldQuery fq = new FieldQuery(pqF("sp", "pe", "ee", "ed"), true, true); // "speed" -(2gram)-> "sp","pe","ee","ed" FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(sppeeeed((88,93)))/1.0(41,141)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void Test1PhraseLongMV() { makeIndexLongMV(); FieldQuery fq = new FieldQuery(pqF("search", "engines"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(searchengines((102,116))searchengines((157,171)))/2.0(87,187)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void Test1PhraseShortMV() { makeIndexShortMV(); FieldQuery fq = new FieldQuery(tq("d"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(d((9,10)))/1.0(0,100)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void Test1PhraseLongMVB() { makeIndexLongMVB(); FieldQuery fq = new FieldQuery(pqF("sp", "pe", "ee", "ed"), true, true); // "speed" -(2gram)-> "sp","pe","ee","ed" FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder(); assertEquals("additional hardware. \nWhen you talk about processing <b>speed</b>, the", sfb.CreateFragment(reader, 0, F, ffl)); }
public void Test1PhraseLongMV() { makeIndexLongMV(); FieldQuery fq = new FieldQuery(pqF("search", "engines"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(searchengines((102,116))searchengines((157,171)))/2.0(87,187)", ffl.FragInfos[0].toString()); }
public void Test1PhraseLongMVB() { makeIndexLongMVB(); FieldQuery fq = new FieldQuery(pqF("sp", "pe", "ee", "ed"), true, true); // "speed" -(2gram)-> "sp","pe","ee","ed" FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(sppeeeed((88,93)))/1.0(41,141)", ffl.FragInfos[0].toString()); }
public void Test1PhraseShortMV() { makeIndexShortMV(); FieldQuery fq = new FieldQuery(tq("d"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(d((9,10)))/1.0(0,100)", ffl.FragInfos[0].toString()); }
public void TestUnstoredField() { makeUnstoredIndex(); FieldQuery fq = new FieldQuery(tq("aaa"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder(); assertNull(sfb.CreateFragment(reader, 0, F, ffl)); }
public void Test1PhraseLongMV() { makeIndexLongMV(); FieldQuery fq = new FieldQuery(pqF("search", "engines"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder(); assertEquals("customization: The most <b>search engines</b> use only one of these methods. Even the <b>search engines</b> that says they can", sfb.CreateFragment(reader, 0, F, ffl)); }
public void Test1PhraseShortMV() { makeIndexShortMV(); FieldQuery fq = new FieldQuery(tq("d"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder(); // Should we probably be trimming? assertEquals(" a b c <b>d</b> e", sfb.CreateFragment(reader, 0, F, ffl)); }
public void TestTooSmallFragSize() { try { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "b c d"), sflb.minFragCharSize - 1); fail("IllegalArgumentException must be thrown"); } #pragma warning disable 168 catch (ArgumentException expected) #pragma warning restore 168 { } }
public void TestMVSeparator() { makeIndexShortMV(); FieldQuery fq = new FieldQuery(tq("d"), true, true); FieldTermStack stack = new FieldTermStack(reader, 0, F, fq); FieldPhraseList fpl = new FieldPhraseList(stack, fq); SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100); SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder(); sfb.MultiValuedSeparator = ('/'); assertEquals("//a b c//<b>d</b> e", sfb.CreateFragment(reader, 0, F, ffl)); }
public void TestPhraseQuerySlop() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); PhraseQuery phraseQuery = new PhraseQuery(); phraseQuery.Slop = (1); phraseQuery.Add(new Term(F, "a")); phraseQuery.Add(new Term(F, "b")); FieldFragList ffl = sflb.CreateFieldFragList(fpl(phraseQuery, "a c b"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(ab((0,1)(4,5)))/1.0(0,20)", ffl.FragInfos[0].toString()); }
public void TestPhraseQuerySlop() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); PhraseQuery phraseQuery = new PhraseQuery(); phraseQuery.Slop = (1); phraseQuery.Add(new Term(F, "a")); phraseQuery.Add(new Term(F, "b")); FieldFragList ffl = sflb.CreateFieldFragList(fpl(phraseQuery, "a c b"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(ab((0,1)(4,5)))/1.0(0,20)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void Test2TermsIndex1Frag() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a a"), 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1))a((2,3)))/2.0(0,100)", ffl.FragInfos[0].toString()); ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a b b b b b b b b a"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1))a((18,19)))/2.0(0,20)", ffl.FragInfos[0].toString()); ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "b b b b a b b b b a"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((8,9))a((18,19)))/2.0(4,24)", ffl.FragInfos[0].toString()); }
public void Test2TermsIndex1Frag() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a a"), 100); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1))a((2,3)))/2.0(0,100)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a b b b b b b b b a"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1))a((18,19)))/2.0(0,20)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "b b b b a b b b b a"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((8,9))a((18,19)))/2.0(4,24)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void TestSmallerFragSizeThanPhraseQuery() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); PhraseQuery phraseQuery = new PhraseQuery(); phraseQuery.Add(new Term(F, "abcdefgh")); phraseQuery.Add(new Term(F, "jklmnopqrs")); FieldFragList ffl = sflb.CreateFieldFragList(fpl(phraseQuery, "abcdefgh jklmnopqrs"), sflb.minFragCharSize); assertEquals(1, ffl.FragInfos.size()); if (VERBOSE) { Console.WriteLine(ffl.FragInfos[0].toString()); } assertEquals("subInfos=(abcdefghjklmnopqrs((0,21)))/1.0(0,21)", ffl.FragInfos[0].toString()); }
public void TestSmallerFragSizeThanPhraseQuery() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); PhraseQuery phraseQuery = new PhraseQuery(); phraseQuery.Add(new Term(F, "abcdefgh")); phraseQuery.Add(new Term(F, "jklmnopqrs")); FieldFragList ffl = sflb.CreateFieldFragList(fpl(phraseQuery, "abcdefgh jklmnopqrs"), sflb.minFragCharSize); assertEquals(1, ffl.FragInfos.size()); if (Verbose) { Console.WriteLine(ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware } assertEquals("subInfos=(abcdefghjklmnopqrs((0,21)))/1.0(0,21)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void Test2TermsIndex2Frags() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a b b b b b b b b b b b b b a"), 20); assertEquals(2, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1)))/1.0(0,20)", ffl.FragInfos[0].toString()); assertEquals("subInfos=(a((28,29)))/1.0(20,40)", ffl.FragInfos[1].toString()); ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a b b b b b b b b b b b b a"), 20); assertEquals(2, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1)))/1.0(0,20)", ffl.FragInfos[0].toString()); assertEquals("subInfos=(a((26,27)))/1.0(20,40)", ffl.FragInfos[1].toString()); ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a b b b b b b b b b a"), 20); assertEquals(2, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1)))/1.0(0,20)", ffl.FragInfos[0].toString()); assertEquals("subInfos=(a((20,21)))/1.0(20,40)", ffl.FragInfos[1].toString()); }
public void Test2TermsIndex2Frags() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); FieldFragList ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a b b b b b b b b b b b b b a"), 20); assertEquals(2, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1)))/1.0(0,20)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware assertEquals("subInfos=(a((28,29)))/1.0(20,40)", ffl.FragInfos[1].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a b b b b b b b b b b b b a"), 20); assertEquals(2, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1)))/1.0(0,20)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware assertEquals("subInfos=(a((26,27)))/1.0(20,40)", ffl.FragInfos[1].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware ffl = sflb.CreateFieldFragList(fpl(new TermQuery(new Term(F, "a")), "a b b b b b b b b b a"), 20); assertEquals(2, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1)))/1.0(0,20)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware assertEquals("subInfos=(a((20,21)))/1.0(20,40)", ffl.FragInfos[1].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
public void Test2TermsQuery() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.Add(new TermQuery(new Term(F, "a")), Occur.SHOULD); booleanQuery.Add(new TermQuery(new Term(F, "b")), Occur.SHOULD); FieldFragList ffl = sflb.CreateFieldFragList(fpl(booleanQuery, "c d e"), 20); assertEquals(0, ffl.FragInfos.size()); ffl = sflb.CreateFieldFragList(fpl(booleanQuery, "d b c"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(b((2,3)))/1.0(0,20)", ffl.FragInfos[0].toString()); ffl = sflb.CreateFieldFragList(fpl(booleanQuery, "a b c"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1))b((2,3)))/2.0(0,20)", ffl.FragInfos[0].toString()); }
public void Test2TermsQuery() { SimpleFragListBuilder sflb = new SimpleFragListBuilder(); BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.Add(new TermQuery(new Term(F, "a")), Occur.SHOULD); booleanQuery.Add(new TermQuery(new Term(F, "b")), Occur.SHOULD); FieldFragList ffl = sflb.CreateFieldFragList(fpl(booleanQuery, "c d e"), 20); assertEquals(0, ffl.FragInfos.size()); ffl = sflb.CreateFieldFragList(fpl(booleanQuery, "d b c"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(b((2,3)))/1.0(0,20)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware ffl = sflb.CreateFieldFragList(fpl(booleanQuery, "a b c"), 20); assertEquals(1, ffl.FragInfos.size()); assertEquals("subInfos=(a((0,1))b((2,3)))/2.0(0,20)", ffl.FragInfos[0].ToString(CultureInfo.InvariantCulture)); // LUCENENET specific: use invariant culture, since we are culture-aware }
private void matchedFieldsTestCase(bool useMatchedFields, bool fieldMatch, String fieldValue, String expected, params Query[] queryClauses) { Document doc = new Document(); FieldType stored = new FieldType(TextField.TYPE_STORED); stored.StoreTermVectorOffsets = (true); stored.StoreTermVectorPositions = (true); stored.StoreTermVectors = (true); stored.Freeze(); FieldType matched = new FieldType(TextField.TYPE_NOT_STORED); matched.StoreTermVectorOffsets = (true); matched.StoreTermVectorPositions = (true); matched.StoreTermVectors = (true); matched.Freeze(); doc.Add(new Field("field", fieldValue, stored)); // Whitespace tokenized with English stop words doc.Add(new Field("field_exact", fieldValue, matched)); // Whitespace tokenized without stop words doc.Add(new Field("field_super_exact", fieldValue, matched)); // Whitespace tokenized without toLower doc.Add(new Field("field_characters", fieldValue, matched)); // Each letter is a token doc.Add(new Field("field_tripples", fieldValue, matched)); // Every three letters is a token doc.Add(new Field("field_sliced", fieldValue.Substring(0, // Sliced at 10 chars then analyzed just like field Math.Min(fieldValue.Length - 1, 10) - 0), matched)); doc.Add(new Field("field_der_red", new CannedTokenStream( // Hacky field containing "der" and "red" at pos = 0 token("der", 1, 0, 3), token("red", 0, 0, 3) ), matched)); Analyzer analyzer = new AnalyzerWrapperAnonymousHelper(); Directory dir = NewDirectory(); IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer)); writer.AddDocument(doc); FastVectorHighlighter highlighter = new FastVectorHighlighter(); IFragListBuilder fragListBuilder = new SimpleFragListBuilder(); IFragmentsBuilder fragmentsBuilder = new ScoreOrderFragmentsBuilder(); IndexReader reader = DirectoryReader.Open(writer, true); String[] preTags = new String[] { "<b>" }; String[] postTags = new String[] { "</b>" }; IEncoder encoder = new DefaultEncoder(); int docId = 0; BooleanQuery query = new BooleanQuery(); foreach (Query clause in queryClauses) { query.Add(clause, Occur.MUST); } FieldQuery fieldQuery = new FieldQuery(query, reader, true, fieldMatch); String[] bestFragments; if (useMatchedFields) { ISet <String> matchedFields = new HashSet <String>(); matchedFields.Add("field"); matchedFields.Add("field_exact"); matchedFields.Add("field_super_exact"); matchedFields.Add("field_characters"); matchedFields.Add("field_tripples"); matchedFields.Add("field_sliced"); matchedFields.Add("field_der_red"); bestFragments = highlighter.GetBestFragments(fieldQuery, reader, docId, "field", matchedFields, 25, 1, fragListBuilder, fragmentsBuilder, preTags, postTags, encoder); } else { bestFragments = highlighter.GetBestFragments(fieldQuery, reader, docId, "field", 25, 1, fragListBuilder, fragmentsBuilder, preTags, postTags, encoder); } assertEquals(expected, bestFragments[0]); reader.Dispose(); writer.Dispose(); dir.Dispose(); }