org.apache.lucene.search.uhighlight

## Class FieldOffsetStrategy

- java.lang.Object
- - org.apache.lucene.search.uhighlight.FieldOffsetStrategy

- Direct Known Subclasses:
    AnalysisOffsetStrategy, NoOpOffsetStrategy, PostingsOffsetStrategy, PostingsWithTermVectorsOffsetStrategy, TermVectorOffsetStrategy

      public abstract class FieldOffsetStrategy
      extends Object

  Ultimately returns a list of `OffsetsEnum` yielding potentially highlightable words in the text. Needs information about the query up front.
  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected CharacterRunAutomaton[]` | `automata`
    `protected String` | `field`
    `protected PhraseHelper` | `phraseHelper`
    `protected BytesRef[]` | `terms`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FieldOffsetStrategy(String field, BytesRef[] queryTerms, PhraseHelper phraseHelper, CharacterRunAutomaton[] automata)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected List<OffsetsEnum>` | `createAutomataOffsetsFromTerms(Terms termsIndex, int doc)`
    `protected List<OffsetsEnum>` | `createOffsetsEnumsFromReader(LeafReader leafReader, int doc)`
    `String` | `getField()`
    `abstract List<OffsetsEnum>` | `getOffsetsEnums(IndexReader reader, int docId, String content)` The primary method -- return offsets for highlightable words in the specified document.
    `abstract UnifiedHighlighter.OffsetSource` | `getOffsetSource()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### field

          protected final String field

    - #### phraseHelper

          protected final PhraseHelper phraseHelper

    - #### terms

          protected final BytesRef[] terms

    - #### automata

          protected final CharacterRunAutomaton[] automata

  - ### Constructor Detail

    - #### FieldOffsetStrategy

          public FieldOffsetStrategy(String field,
                                     BytesRef[] queryTerms,
                                     PhraseHelper phraseHelper,
                                     CharacterRunAutomaton[] automata)

  - ### Method Detail

    - #### getField

          public String getField()

    - #### getOffsetSource

          public abstract UnifiedHighlighter.OffsetSource getOffsetSource()

    - #### getOffsetsEnums

          public abstract List<OffsetsEnum> getOffsetsEnums(IndexReader reader,
                                                            int docId,
                                                            String content)
                                                     throws IOException

      The primary method -- return offsets for highlightable words in the specified document. IMPORTANT: remember to close them all.
      Throws:
        `IOException`

    - #### createOffsetsEnumsFromReader

          protected List<OffsetsEnum> createOffsetsEnumsFromReader(LeafReader leafReader,
                                                                   int doc)
                                                            throws IOException

      Throws:
        `IOException`

    - #### createAutomataOffsetsFromTerms

          protected List<OffsetsEnum> createAutomataOffsetsFromTerms(Terms termsIndex,
                                                                     int doc)
                                                              throws IOException

      Throws:
        `IOException`

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.