public class UnifiedSolrHighlighter extends SolrHighlighter implements PluginInfoInitialized
UnifiedHighlighter
Example configuration with default values:
<requestHandler name="/select" class="solr.SearchHandler"> <lst name="defaults"> <str name="hl.method">unified</str> <int name="hl.snippets">1</int> <str name="hl.tag.pre"><em></str> <str name="hl.tag.post"></em></str> <str name="hl.simple.pre"><em></str> <str name="hl.simple.post"></em></str> <str name="hl.tag.ellipsis">(internal/unspecified)</str> <bool name="hl.defaultSummary">false</bool> <str name="hl.encoder">simple</str> <float name="hl.score.k1">1.2</float> <float name="hl.score.b">0.75</float> <float name="hl.score.pivot">87</float> <str name="hl.bs.language"></str> <str name="hl.bs.country"></str> <str name="hl.bs.variant"></str> <str name="hl.bs.type">SENTENCE</str> <int name="hl.maxAnalyzedChars">51200</int> <bool name="hl.highlightMultiTerm">true</bool> <bool name="hl.usePhraseHighlighter">true</bool> <int name="hl.cacheFieldValCharsThreshold">524288</int> <str name="hl.offsetSource"></str> </lst> </requestHandler>
Notes:
Modifier and Type | Class and Description |
---|---|
protected static class |
UnifiedSolrHighlighter.SolrExtendedUnifiedHighlighter
|
Modifier and Type | Field and Description |
---|---|
protected static String |
SNIPPET_SEPARATOR |
DEFAULT_MAX_CHARS, DEFAULT_PHRASE_LIMIT
Constructor and Description |
---|
UnifiedSolrHighlighter() |
Modifier and Type | Method and Description |
---|---|
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 NamedList<Object> |
encodeSnippets(String[] keys,
String[] fieldNames,
Map<String,String[]> snippets)
Encodes the resulting snippets into a namedlist
|
protected UnifiedHighlighter |
getHighlighter(SolrQueryRequest req)
Creates an instance of the Lucene
UnifiedHighlighter . |
protected String[] |
getUniqueKeys(SolrIndexSearcher searcher,
int[] docIDs)
Retrieves the unique keys for the topdocs to key the results
|
void |
init(PluginInfo info) |
protected int[] |
toDocIDs(DocList docs)
Converts solr's DocList to the int[] docIDs
|
emptyArray, getHighlightFields, isHighlightingEnabled
protected static final String SNIPPET_SEPARATOR
public void init(PluginInfo info)
init
in interface PluginInfoInitialized
public NamedList<Object> doHighlighting(DocList docs, Query query, SolrQueryRequest req, String[] defaultFields) throws IOException
SolrHighlighter
doHighlighting
in class SolrHighlighter
docs
- query resultsquery
- the queryreq
- the current requestdefaultFields
- default list of fields to summarizeIOException
protected UnifiedHighlighter getHighlighter(SolrQueryRequest req)
UnifiedHighlighter
. Provided for subclass extension so that
a subclass can return a subclass of UnifiedSolrHighlighter.SolrExtendedUnifiedHighlighter
.protected NamedList<Object> encodeSnippets(String[] keys, String[] fieldNames, Map<String,String[]> snippets)
keys
- the document unique keysfieldNames
- field names to highlight in the ordersnippets
- map from field name to snippet array for the docsprotected int[] toDocIDs(DocList docs)
protected String[] getUniqueKeys(SolrIndexSearcher searcher, int[] docIDs) throws IOException
IOException
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.