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

Package org.apache.lucene.search.matchhighlight

# Class MatchHighlighter

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

public class MatchHighlighter extends Object
An example highlighter that combines several lower-level utility classes in this package into a fully featured, ready-to-use component.

Note: if you need to customize or tweak the details of highlighting, it is better to assemble your own highlighter using those low-level building blocks, rather than extend or modify this one.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `MatchHighlighter.DocHighlights`
  Single document's highlights.
  `static interface`
  `MatchHighlighter.FieldValueHighlighter`
  Actual per-field highlighter.
  `static class`
  `MatchHighlighter.QueryOffsetRange`
  An `OffsetRange` of a match, together with the source query that caused it.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MatchHighlighter(IndexSearcher searcher, Analyzer analyzer)`
  `MatchHighlighter(IndexSearcher searcher, Analyzer analyzer, OffsetsRetrievalStrategySupplier offsetsRetrievalStrategies)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `alwaysFetchFields(String... fields)`
  Always fetch the given set of fields for all input documents.
  `MatchHighlighter`
  `appendFieldHighlighter(MatchHighlighter.FieldValueHighlighter highlighter)`
  Append a new highlighter to field highlighters chain.
  `Stream<MatchHighlighter.DocHighlights>`
  `highlight(TopDocs topDocs, Query... queries)`

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

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

- ## Constructor Details

  - ### MatchHighlighter

    public MatchHighlighter(IndexSearcher searcher, Analyzer analyzer)

  - ### MatchHighlighter

    public MatchHighlighter(IndexSearcher searcher, Analyzer analyzer, OffsetsRetrievalStrategySupplier offsetsRetrievalStrategies)

- ## Method Details

  - ### appendFieldHighlighter

    public MatchHighlighter appendFieldHighlighter(MatchHighlighter.FieldValueHighlighter highlighter)
    Append a new highlighter to field highlighters chain. The order of field highlighters is important (first-matching wins).

  - ### alwaysFetchFields

    public void alwaysFetchFields(String... fields)
    Always fetch the given set of fields for all input documents.

  - ### highlight

    public Stream<MatchHighlighter.DocHighlights> highlight(TopDocs topDocs, Query... queries) throws IOException
    Throws:
      `IOException`