public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInfoInitialized
Modifier and Type | Class and Description |
---|---|
static class |
DefaultSolrHighlighter.FvhContainer |
Modifier and Type | Field and Description |
---|---|
protected Map<String,SolrBoundaryScanner> |
boundaryScanners |
protected Map<String,SolrEncoder> |
encoders |
protected Map<String,SolrFormatter> |
formatters |
protected Map<String,SolrFragListBuilder> |
fragListBuilders |
protected Map<String,SolrFragmenter> |
fragmenters |
protected Map<String,SolrFragmentsBuilder> |
fragmentsBuilders |
protected SolrCore |
solrCore |
DEFAULT_MAX_CHARS, DEFAULT_PHRASE_LIMIT
Constructor and Description |
---|
DefaultSolrHighlighter(SolrCore solrCore) |
Modifier and Type | Method and Description |
---|---|
protected Object |
alternateField(Document doc,
int docId,
String fieldName,
DefaultSolrHighlighter.FvhContainer fvhContainer,
Query query,
IndexReader reader,
SolrQueryRequest req)
Returns the alternate highlight object for this field -- a String[] by default.
|
protected TokenStream |
createAnalyzerTStream(SchemaField schemaField,
String docText) |
NamedList<Object> |
doHighlighting(DocList docs,
Query query,
SolrQueryRequest req,
String[] defaultFields)
Generates a list of Highlighted query fragments for each item in a list
of documents, or returns null if highlighting is disabled.
|
protected Object |
doHighlightingByFastVectorHighlighter(Document doc,
int docId,
SchemaField schemaField,
DefaultSolrHighlighter.FvhContainer fvhContainer,
IndexReader reader,
SolrQueryRequest req)
Highlights and returns the highlight object for this field -- a String[] by default.
|
protected Object |
doHighlightingByHighlighter(Document doc,
int docId,
SchemaField schemaField,
Query query,
IndexReader reader,
SolrQueryRequest req)
Highlights and returns the highlight object for this field -- a String[] by default.
|
protected Object |
doHighlightingOfField(Document doc,
int docId,
SchemaField schemaField,
DefaultSolrHighlighter.FvhContainer fvhContainer,
Query query,
IndexReader reader,
SolrQueryRequest req,
SolrParams params) |
protected BoundaryScanner |
getBoundaryScanner(String fieldName,
SolrParams params) |
protected Set<String> |
getDocPrefetchFieldNames(String[] hlFieldNames,
SolrQueryRequest req)
Returns the field names to be passed to
SolrIndexSearcher.doc(int, Set) . |
protected Encoder |
getEncoder(String fieldName,
SolrParams params)
Return an
Encoder appropriate for this field. |
protected List<String> |
getFieldValues(Document doc,
String fieldName,
int maxValues,
int maxCharsToAnalyze,
SolrQueryRequest req)
Fetches field values to highlight.
|
protected Formatter |
getFormatter(String fieldName,
SolrParams params)
Return a
Formatter appropriate for this field. |
protected FragListBuilder |
getFragListBuilder(String fieldName,
SolrParams params) |
protected Fragmenter |
getFragmenter(String fieldName,
SolrParams params)
Return a
Fragmenter appropriate for this field. |
protected FragmentsBuilder |
getFragmentsBuilder(String fieldName,
SolrParams params) |
protected Highlighter |
getHighlighter(Query query,
String fieldName,
SolrQueryRequest request)
Return a
Highlighter appropriate for this field. |
protected int |
getMaxSnippets(String fieldName,
SolrParams params)
Return the max number of snippets for this field.
|
protected Highlighter |
getPhraseHighlighter(Query query,
String fieldName,
SolrQueryRequest request,
TokenStream tokenStream)
Return a phrase
Highlighter appropriate for this field. |
protected Scorer |
getQueryScorer(Query query,
String fieldName,
SolrQueryRequest request)
Return a
Scorer suitable for this Query and field. |
protected Object |
getResponseForFragments(List<TextFragment> frags,
SolrQueryRequest req)
Given the fragments, return the result to be put in the field
NamedList . |
protected SolrFragmentsBuilder |
getSolrFragmentsBuilder(String fieldName,
SolrParams params) |
protected QueryScorer |
getSpanQueryScorer(Query query,
String fieldName,
TokenStream tokenStream,
SolrQueryRequest request)
Return a
QueryScorer suitable for this Query and field. |
void |
init(PluginInfo info) |
protected boolean |
isMergeContiguousFragments(String fieldName,
SolrParams params)
Return whether adjacent fragments should be merged.
|
protected boolean |
useFastVectorHighlighter(SolrParams params,
SchemaField schemaField)
Determines if we should use the FastVectorHighlighter for this field.
|
emptyArray, getHighlightFields, isHighlightingEnabled
protected final SolrCore solrCore
protected final Map<String,SolrFormatter> formatters
protected final Map<String,SolrEncoder> encoders
protected final Map<String,SolrFragmenter> fragmenters
protected final Map<String,SolrFragListBuilder> fragListBuilders
protected final Map<String,SolrFragmentsBuilder> fragmentsBuilders
protected final Map<String,SolrBoundaryScanner> boundaryScanners
public DefaultSolrHighlighter(SolrCore solrCore)
public void init(PluginInfo info)
init
in interface PluginInfoInitialized
protected Highlighter getPhraseHighlighter(Query query, String fieldName, SolrQueryRequest request, TokenStream tokenStream) throws IOException
Highlighter
appropriate for this field.query
- The current QueryfieldName
- The name of the fieldrequest
- The current SolrQueryRequesttokenStream
- document text tokenStream that implements reset() efficiently (e.g. CachingTokenFilter).
If it's used, call reset() first.IOException
- If there is a low-level I/O error.protected Highlighter getHighlighter(Query query, String fieldName, SolrQueryRequest request)
Highlighter
appropriate for this field.query
- The current QueryfieldName
- The name of the fieldrequest
- The current SolrQueryRequestprotected QueryScorer getSpanQueryScorer(Query query, String fieldName, TokenStream tokenStream, SolrQueryRequest request)
QueryScorer
suitable for this Query and field.query
- The current querytokenStream
- document text tokenStream that implements reset() efficiently (e.g. CachingTokenFilter).
If it's used, call reset() first.fieldName
- The name of the fieldrequest
- The SolrQueryRequestprotected Scorer getQueryScorer(Query query, String fieldName, SolrQueryRequest request)
Scorer
suitable for this Query and field.query
- The current queryfieldName
- The name of the fieldrequest
- The SolrQueryRequestprotected int getMaxSnippets(String fieldName, SolrParams params)
fieldName
- The name of the fieldparams
- The params controlling Highlightingprotected boolean isMergeContiguousFragments(String fieldName, SolrParams params)
fieldName
- The name of the fieldparams
- The params controlling Highlightingprotected Formatter getFormatter(String fieldName, SolrParams params)
Formatter
appropriate for this field. If a formatter
has not been configured for this field, fall back to the configured
default or the solr default (SimpleHTMLFormatter
).fieldName
- The name of the fieldparams
- The params controlling HighlightingFormatter
.protected Encoder getEncoder(String fieldName, SolrParams params)
Encoder
appropriate for this field. If an encoder
has not been configured for this field, fall back to the configured
default or the solr default (DefaultEncoder
).fieldName
- The name of the fieldparams
- The params controlling HighlightingEncoder
.protected Fragmenter getFragmenter(String fieldName, SolrParams params)
Fragmenter
appropriate for this field. If a fragmenter
has not been configured for this field, fall back to the configured
default or the solr default (GapFragmenter
).fieldName
- The name of the fieldparams
- The params controlling HighlightingFragmenter
.protected FragListBuilder getFragListBuilder(String fieldName, SolrParams params)
protected FragmentsBuilder getFragmentsBuilder(String fieldName, SolrParams params)
protected SolrFragmentsBuilder getSolrFragmentsBuilder(String fieldName, SolrParams params)
protected BoundaryScanner getBoundaryScanner(String fieldName, SolrParams params)
public NamedList<Object> doHighlighting(DocList docs, Query query, SolrQueryRequest req, String[] defaultFields) throws IOException
doHighlighting
in class SolrHighlighter
docs
- query resultsquery
- the queryreq
- the current requestdefaultFields
- default list of fields to summarizeIOException
protected Object doHighlightingOfField(Document doc, int docId, SchemaField schemaField, DefaultSolrHighlighter.FvhContainer fvhContainer, Query query, IndexReader reader, SolrQueryRequest req, SolrParams params) throws IOException
IOException
protected Set<String> getDocPrefetchFieldNames(String[] hlFieldNames, SolrQueryRequest req)
SolrIndexSearcher.doc(int, Set)
.
Subclasses might over-ride to include fields in search-results and other stored field values needed so as to avoid
the possibility of extra trips to disk. The uniqueKey will be added after if the result isn't null.protected boolean useFastVectorHighlighter(SolrParams params, SchemaField schemaField)
protected Object doHighlightingByFastVectorHighlighter(Document doc, int docId, SchemaField schemaField, DefaultSolrHighlighter.FvhContainer fvhContainer, IndexReader reader, SolrQueryRequest req) throws IOException
IOException
protected Object doHighlightingByHighlighter(Document doc, int docId, SchemaField schemaField, Query query, IndexReader reader, SolrQueryRequest req) throws IOException
IOException
protected List<String> getFieldValues(Document doc, String fieldName, int maxValues, int maxCharsToAnalyze, SolrQueryRequest req)
protected Object getResponseForFragments(List<TextFragment> frags, SolrQueryRequest req)
NamedList
. This is an extension
point to allow adding other metadata like the absolute offsets or scores.protected Object alternateField(Document doc, int docId, String fieldName, DefaultSolrHighlighter.FvhContainer fvhContainer, Query query, IndexReader reader, SolrQueryRequest req) throws IOException
IOException
protected TokenStream createAnalyzerTStream(SchemaField schemaField, String docText) throws IOException
IOException
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.