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

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `FieldHighlighter​(String field, FieldOffsetStrategy fieldOffsetStrategy, BreakIterator breakIterator, PassageScorer passageScorer, int maxPassages, int maxNoHighlightPassages, PassageFormatter passageFormatter)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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 Detail

    - #### 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

  - ### Constructor Detail

    - #### FieldHighlighter

          public FieldHighlighter​(String field,
                                  FieldOffsetStrategy fieldOffsetStrategy,
                                  BreakIterator breakIterator,
                                  PassageScorer passageScorer,
                                  int maxPassages,
                                  int maxNoHighlightPassages,
                                  PassageFormatter passageFormatter)

  - ### Method Detail

    - #### 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`