Class MatchHighlighter
java.lang.Object
org.apache.lucene.search.matchhighlight.MatchHighlighter
An example highlighter that combines several lower-level highlighting utilities in this package
into a fully featured, ready-to-use component.
Note that 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 ClassesModifier and TypeClassDescriptionstatic classSingle document's highlights.private static classstatic interfaceActual per-field highlighter.static classAnOffsetRangeof a match, together with the source query that caused it. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Analyzerprivate final List<MatchHighlighter.FieldValueHighlighter> private final OffsetsRetrievalStrategySupplierprivate final IndexSearcher -
Constructor Summary
ConstructorsConstructorDescriptionMatchHighlighter(IndexSearcher searcher, Analyzer analyzer) MatchHighlighter(IndexSearcher searcher, Analyzer analyzer, OffsetsRetrievalStrategySupplier offsetsRetrievalStrategies) -
Method Summary
Modifier and TypeMethodDescriptionvoidalwaysFetchFields(String... fields) Always fetch the given set of fields for all input documents.Append a new highlighter to field highlighters chain.private MatchHighlighter.DocHighlightsprivate List<OffsetRange> computeValueRanges(String field, String[] values) private StringcontiguousFieldValue(String field, String[] values) fieldValueHighlighter(String field, boolean hasMatches)
-
Field Details
-
searcher
-
offsetsRetrievalStrategies
-
analyzer
-
fieldsAlwaysReturned
-
fieldHighlighters
-
-
Constructor Details
-
MatchHighlighter
-
MatchHighlighter
public MatchHighlighter(IndexSearcher searcher, Analyzer analyzer, OffsetsRetrievalStrategySupplier offsetsRetrievalStrategies)
-
-
Method Details
-
appendFieldHighlighter
Append a new highlighter to field highlighters chain. The order of field highlighters is important (first-matching wins). -
alwaysFetchFields
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
-
computeDocFieldValues
-
computeValueRanges
-
contiguousFieldValue
-
fieldValueHighlighter
private MatchHighlighter.FieldValueHighlighter fieldValueHighlighter(String field, boolean hasMatches)
-