FieldValueHighlighters (Lucene 10.5.1 highlighter API)
Description: declaration: package: org.apache.lucene.search.matchhighlight, class: FieldValueHighlighters

Package org.apache.lucene.search.matchhighlight

# Class FieldValueHighlighters

java.lang.Object
org.apache.lucene.search.matchhighlight.FieldValueHighlighters

public final class FieldValueHighlighters extends Object
A factory of `MatchHighlighter.FieldValueHighlighter` classes that cover typical use cases (verbatim values, highlights, abbreviations).

See Also:
  - `MatchHighlighter.appendFieldHighlighter(org.apache.lucene.search.matchhighlight.MatchHighlighter.FieldValueHighlighter)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static PassageSelector`
  `defaultPassageSelector()`
  Default preconfigured `PassageSelector`.
  `static MatchHighlighter.FieldValueHighlighter`
  `highlighted(int maxPassageWindow, int maxPassages, PassageFormatter passageFormatter, Predicate<String> matchFields)`
  Highlights fields matching predicate `matchFields` only if they contained query matches.
  `static MatchHighlighter.FieldValueHighlighter`
  `maxLeadingCharacters(int maxLeadingCharacters, String ellipsis, Set<String> fields)`
  Displays up to `maxLeadingCharacters` of the field's value, regardless of whether it contained highlights or not.
  `static MatchHighlighter.FieldValueHighlighter`
  `skipRemaining()`
  Matches all fields and omits their value in the output (so that no highlight or value is emitted).
  `static MatchHighlighter.FieldValueHighlighter`
  `verbatimValue(String field, String... moreFields)`
  Always returns raw field values, no highlighting or value truncation is applied.

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

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

- ## Method Details

  - ### maxLeadingCharacters

    public static MatchHighlighter.FieldValueHighlighter maxLeadingCharacters(int maxLeadingCharacters, String ellipsis, Set<String> fields)
    Displays up to `maxLeadingCharacters` of the field's value, regardless of whether it contained highlights or not.

  - ### defaultPassageSelector

    public static PassageSelector defaultPassageSelector()
    Default preconfigured `PassageSelector`.

  - ### highlighted

    public static MatchHighlighter.FieldValueHighlighter highlighted(int maxPassageWindow, int maxPassages, PassageFormatter passageFormatter, Predicate<String> matchFields)
    Highlights fields matching predicate `matchFields` only if they contained query matches.

  - ### verbatimValue

    public static MatchHighlighter.FieldValueHighlighter verbatimValue(String field, String... moreFields)
    Always returns raw field values, no highlighting or value truncation is applied.

  - ### skipRemaining

    public static MatchHighlighter.FieldValueHighlighter skipRemaining()
    Matches all fields and omits their value in the output (so that no highlight or value is emitted).