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 class
Single document's highlights.private static class
static interface
Actual per-field highlighter.static class
AnOffsetRange
of a match, together with the source query that caused it. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Analyzer
private final List
<MatchHighlighter.FieldValueHighlighter> private final OffsetsRetrievalStrategySupplier
private final IndexSearcher
-
Constructor Summary
ConstructorsConstructorDescriptionMatchHighlighter
(IndexSearcher searcher, Analyzer analyzer) MatchHighlighter
(IndexSearcher searcher, Analyzer analyzer, OffsetsRetrievalStrategySupplier offsetsRetrievalStrategies) -
Method Summary
Modifier and TypeMethodDescriptionvoid
alwaysFetchFields
(String... fields) Always fetch the given set of fields for all input documents.Append a new highlighter to field highlighters chain.private MatchHighlighter.DocHighlights
private List
<OffsetRange> computeValueRanges
(String field, String[] values) private String
contiguousFieldValue
(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)
-