Package org.apache.lucene.search.uhighlight

# Class FieldHighlighter

java.lang.Object
org.apache.lucene.search.uhighlight.FieldHighlighter

public class FieldHighlighter extends Object
Internal highlighter abstraction that operates on a per field basis.

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
  Description
  `protected final BreakIterator`
  `breakIterator`
  `protected final String`
  `field`
  `protected final FieldOffsetStrategy`
  `fieldOffsetStrategy`
  `protected final int`
  `maxNoHighlightPassages`
  `protected final int`
  `maxPassages`
  `protected final PassageFormatter`
  `passageFormatter`
  `protected final PassageScorer`
  `passageScorer`
  `protected final Comparator<Passage>`
  `passageSortComparator`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FieldHighlighter(String field, FieldOffsetStrategy fieldOffsetStrategy, BreakIterator breakIterator, PassageScorer passageScorer, int maxPassages, int maxNoHighlightPassages, PassageFormatter passageFormatter, Comparator<Passage> passageSortComparator)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getField()`
  `UnifiedHighlighter.OffsetSource`
  `getOffsetSource()`
  `protected Passage[]`
  `getSummaryPassagesNoHighlight(int maxPassages)`
  Called to summarize a document when no highlights were found.
  `Object`
  `highlightFieldForDoc(LeafReader reader, int docId, String content)`
  The primary method -- highlight this doc, assuming a specific field and given this content.
  `protected Passage[]`
  `highlightOffsetsEnums(OffsetsEnum off)`

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

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

- ## Field Details

  - ### field

    protected final String field

  - ### fieldOffsetStrategy

    protected final FieldOffsetStrategy fieldOffsetStrategy

  - ### breakIterator

    protected final BreakIterator breakIterator

  - ### passageScorer

    protected final PassageScorer passageScorer

  - ### maxPassages

    protected final int maxPassages

  - ### maxNoHighlightPassages

    protected final int maxNoHighlightPassages

  - ### passageFormatter

    protected final PassageFormatter passageFormatter

  - ### passageSortComparator

    protected final Comparator<Passage> passageSortComparator

- ## Constructor Details

  - ### FieldHighlighter

    public FieldHighlighter(String field, FieldOffsetStrategy fieldOffsetStrategy, BreakIterator breakIterator, PassageScorer passageScorer, int maxPassages, int maxNoHighlightPassages, PassageFormatter passageFormatter, Comparator<Passage> passageSortComparator)

- ## Method Details

  - ### getField

    public String getField()

  - ### getOffsetSource

    public UnifiedHighlighter.OffsetSource getOffsetSource()

  - ### highlightFieldForDoc

    public Object highlightFieldForDoc(LeafReader reader, int docId, String content) throws IOException
    The primary method -- highlight this doc, assuming a specific field and given this content.
    Throws:
      `IOException`

  - ### getSummaryPassagesNoHighlight

    protected Passage[] getSummaryPassagesNoHighlight(int maxPassages)
    Called to summarize a document when no highlights were found. By default this just returns the first `maxPassages` sentences; subclasses can override to customize. The state of `breakIterator` should be at the beginning.

  - ### highlightOffsetsEnums

    protected Passage[] highlightOffsetsEnums(OffsetsEnum off) throws IOException
    Throws:
      `IOException`