Search in sources :

Example 1 with OffsetsEnum

use of org.apache.lucene.search.uhighlight.OffsetsEnum in project lucene-solr by apache.

the class TestUnifiedHighlighterExtensibility method testFieldOffsetStrategyExtensibility.

/**
   * This test is for maintaining the extensibility of the FieldOffsetStrategy
   * for customizations out of package.
   */
@Test
public void testFieldOffsetStrategyExtensibility() {
    final UnifiedHighlighter.OffsetSource offsetSource = UnifiedHighlighter.OffsetSource.NONE_NEEDED;
    FieldOffsetStrategy strategy = new FieldOffsetStrategy("field", new BytesRef[0], PhraseHelper.NONE, new CharacterRunAutomaton[0]) {

        @Override
        public UnifiedHighlighter.OffsetSource getOffsetSource() {
            return offsetSource;
        }

        @Override
        public List<OffsetsEnum> getOffsetsEnums(IndexReader reader, int docId, String content) throws IOException {
            return Collections.emptyList();
        }

        @Override
        protected List<OffsetsEnum> createOffsetsEnumsFromReader(LeafReader leafReader, int doc) throws IOException {
            return super.createOffsetsEnumsFromReader(leafReader, doc);
        }
    };
    assertEquals(offsetSource, strategy.getOffsetSource());
}
Also used : FieldOffsetStrategy(org.apache.lucene.search.uhighlight.FieldOffsetStrategy) LeafReader(org.apache.lucene.index.LeafReader) UnifiedHighlighter(org.apache.lucene.search.uhighlight.UnifiedHighlighter) IndexReader(org.apache.lucene.index.IndexReader) OffsetsEnum(org.apache.lucene.search.uhighlight.OffsetsEnum) Test(org.junit.Test)

Aggregations

IndexReader (org.apache.lucene.index.IndexReader)1 LeafReader (org.apache.lucene.index.LeafReader)1 FieldOffsetStrategy (org.apache.lucene.search.uhighlight.FieldOffsetStrategy)1 OffsetsEnum (org.apache.lucene.search.uhighlight.OffsetsEnum)1 UnifiedHighlighter (org.apache.lucene.search.uhighlight.UnifiedHighlighter)1 Test (org.junit.Test)1