Package org.apache.solr.highlight
Class DefaultSolrHighlighter
- java.lang.Object
- 
- org.apache.solr.highlight.SolrHighlighter
- 
- org.apache.solr.highlight.DefaultSolrHighlighter
 
 
- 
- All Implemented Interfaces:
- PluginInfoInitialized
 
 public class DefaultSolrHighlighter extends SolrHighlighter implements PluginInfoInitialized - Since:
- solr 1.3
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classDefaultSolrHighlighter.FvhContainer
 - 
Field SummaryFields Modifier and Type Field Description protected Map<String,SolrBoundaryScanner>boundaryScannersprotected Map<String,SolrEncoder>encodersprotected Map<String,SolrFormatter>formattersprotected Map<String,SolrFragListBuilder>fragListBuildersprotected Map<String,SolrFragmenter>fragmentersprotected Map<String,SolrFragmentsBuilder>fragmentsBuildersprotected SolrCoresolrCore- 
Fields inherited from class org.apache.solr.highlight.SolrHighlighterDEFAULT_MAX_CHARS, DEFAULT_PHRASE_LIMIT
 
- 
 - 
Constructor SummaryConstructors Constructor Description DefaultSolrHighlighter(SolrCore solrCore)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectalternateField(SolrDocument doc, int docId, String fieldName, DefaultSolrHighlighter.FvhContainer fvhContainer, org.apache.lucene.search.Query query, org.apache.lucene.index.IndexReader reader, SolrQueryRequest req)Returns the alternate highlight object for this field -- a String[] by default.protected org.apache.lucene.analysis.TokenStreamcreateAnalyzerTStream(SchemaField schemaField, String docText)NamedList<Object>doHighlighting(DocList docs, org.apache.lucene.search.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 ObjectdoHighlightingByFastVectorHighlighter(SolrDocument doc, int docId, SchemaField schemaField, DefaultSolrHighlighter.FvhContainer fvhContainer, org.apache.lucene.index.IndexReader reader, SolrQueryRequest req)Highlights and returns the highlight object for this field -- a String[] by default.protected ObjectdoHighlightingByHighlighter(SolrDocument doc, int docId, SchemaField schemaField, org.apache.lucene.search.Query query, org.apache.lucene.index.IndexReader reader, SolrQueryRequest req)Highlights and returns the highlight object for this field -- a String[] by default.protected ObjectdoHighlightingOfField(SolrDocument doc, int docId, SchemaField schemaField, DefaultSolrHighlighter.FvhContainer fvhContainer, org.apache.lucene.search.Query query, org.apache.lucene.index.IndexReader reader, SolrQueryRequest req, SolrParams params)protected org.apache.lucene.search.vectorhighlight.BoundaryScannergetBoundaryScanner(String fieldName, SolrParams params)protected Set<String>getDocPrefetchFieldNames(String[] hlFieldNames, SolrQueryRequest req)Returns the field names to be passed toSolrDocumentFetcher.solrDoc(int, SolrReturnFields).protected org.apache.lucene.search.highlight.EncodergetEncoder(String fieldName, SolrParams params)Return anEncoderappropriate for this field.protected List<String>getFieldValues(SolrDocument doc, String fieldName, int maxValues, int maxCharsToAnalyze, SolrQueryRequest req)Fetches field values to highlight.protected org.apache.lucene.search.highlight.FormattergetFormatter(String fieldName, SolrParams params)Return aFormatterappropriate for this field.protected org.apache.lucene.search.vectorhighlight.FragListBuildergetFragListBuilder(String fieldName, SolrParams params)protected org.apache.lucene.search.highlight.FragmentergetFragmenter(String fieldName, SolrParams params)Return aFragmenterappropriate for this field.protected org.apache.lucene.search.vectorhighlight.FragmentsBuildergetFragmentsBuilder(String fieldName, SolrParams params)protected org.apache.lucene.search.highlight.HighlightergetHighlighter(org.apache.lucene.search.Query query, String fieldName, SolrQueryRequest request)Return aHighlighterappropriate for this field.protected intgetMaxSnippets(String fieldName, SolrParams params)Return the max number of snippets for this field.protected org.apache.lucene.search.highlight.HighlightergetPhraseHighlighter(org.apache.lucene.search.Query query, String fieldName, SolrQueryRequest request, org.apache.lucene.analysis.TokenStream tokenStream)Return a phraseHighlighterappropriate for this field.protected org.apache.lucene.search.highlight.ScorergetQueryScorer(org.apache.lucene.search.Query query, String fieldName, SolrQueryRequest request)Return aScorersuitable for this Query and field.protected ObjectgetResponseForFragments(List<org.apache.lucene.search.highlight.TextFragment> frags, SolrQueryRequest req)Given the fragments, return the result to be put in the fieldNamedList.protected SolrFragmentsBuildergetSolrFragmentsBuilder(String fieldName, SolrParams params)protected org.apache.lucene.search.highlight.QueryScorergetSpanQueryScorer(org.apache.lucene.search.Query query, String fieldName, org.apache.lucene.analysis.TokenStream tokenStream, SolrQueryRequest request)Return aQueryScorersuitable for this Query and field.voidinit(PluginInfo info)protected booleanisMergeContiguousFragments(String fieldName, SolrParams params)Return whether adjacent fragments should be merged.protected booleanuseFastVectorHighlighter(SolrParams params, SchemaField schemaField)Determines if we should use the FastVectorHighlighter for this field.- 
Methods inherited from class org.apache.solr.highlight.SolrHighlighteremptyArray, getHighlightFields, isHighlightingEnabled
 
- 
 
- 
- 
- 
Field Detail- 
solrCoreprotected final SolrCore solrCore 
 - 
formattersprotected final Map<String,SolrFormatter> formatters 
 - 
encodersprotected final Map<String,SolrEncoder> encoders 
 - 
fragmentersprotected final Map<String,SolrFragmenter> fragmenters 
 - 
fragListBuildersprotected final Map<String,SolrFragListBuilder> fragListBuilders 
 - 
fragmentsBuildersprotected final Map<String,SolrFragmentsBuilder> fragmentsBuilders 
 - 
boundaryScannersprotected final Map<String,SolrBoundaryScanner> boundaryScanners 
 
- 
 - 
Constructor Detail- 
DefaultSolrHighlighterpublic DefaultSolrHighlighter(SolrCore solrCore) 
 
- 
 - 
Method Detail- 
initpublic void init(PluginInfo info) - Specified by:
- initin interface- PluginInfoInitialized
 
 - 
getPhraseHighlighterprotected org.apache.lucene.search.highlight.Highlighter getPhraseHighlighter(org.apache.lucene.search.Query query, String fieldName, SolrQueryRequest request, org.apache.lucene.analysis.TokenStream tokenStream) throws IOExceptionReturn a phraseHighlighterappropriate for this field.- Parameters:
- query- The current Query
- fieldName- The name of the field
- request- The current SolrQueryRequest
- tokenStream- document text tokenStream that implements reset() efficiently (e.g. CachingTokenFilter). If it's used, call reset() first.
- Throws:
- IOException- If there is a low-level I/O error.
 
 - 
getHighlighterprotected org.apache.lucene.search.highlight.Highlighter getHighlighter(org.apache.lucene.search.Query query, String fieldName, SolrQueryRequest request)Return aHighlighterappropriate for this field.- Parameters:
- query- The current Query
- fieldName- The name of the field
- request- The current SolrQueryRequest
 
 - 
getSpanQueryScorerprotected org.apache.lucene.search.highlight.QueryScorer getSpanQueryScorer(org.apache.lucene.search.Query query, String fieldName, org.apache.lucene.analysis.TokenStream tokenStream, SolrQueryRequest request)Return aQueryScorersuitable for this Query and field.- Parameters:
- query- The current query
- tokenStream- document text tokenStream that implements reset() efficiently (e.g. CachingTokenFilter). If it's used, call reset() first.
- fieldName- The name of the field
- request- The SolrQueryRequest
 
 - 
getQueryScorerprotected org.apache.lucene.search.highlight.Scorer getQueryScorer(org.apache.lucene.search.Query query, String fieldName, SolrQueryRequest request)Return aScorersuitable for this Query and field.- Parameters:
- query- The current query
- fieldName- The name of the field
- request- The SolrQueryRequest
 
 - 
getMaxSnippetsprotected int getMaxSnippets(String fieldName, SolrParams params) Return the max number of snippets for this field. If this has not been configured for this field, fall back to the configured default or the solr default.- Parameters:
- fieldName- The name of the field
- params- The params controlling Highlighting
 
 - 
isMergeContiguousFragmentsprotected boolean isMergeContiguousFragments(String fieldName, SolrParams params) Return whether adjacent fragments should be merged.- Parameters:
- fieldName- The name of the field
- params- The params controlling Highlighting
 
 - 
getFormatterprotected org.apache.lucene.search.highlight.Formatter getFormatter(String fieldName, SolrParams params) Return aFormatterappropriate for this field. If a formatter has not been configured for this field, fall back to the configured default or the solr default (SimpleHTMLFormatter).- Parameters:
- fieldName- The name of the field
- params- The params controlling Highlighting
- Returns:
- An appropriate Formatter.
 
 - 
getEncoderprotected org.apache.lucene.search.highlight.Encoder getEncoder(String fieldName, SolrParams params) Return anEncoderappropriate for this field. If an encoder has not been configured for this field, fall back to the configured default or the solr default (DefaultEncoder).- Parameters:
- fieldName- The name of the field
- params- The params controlling Highlighting
- Returns:
- An appropriate Encoder.
 
 - 
getFragmenterprotected org.apache.lucene.search.highlight.Fragmenter getFragmenter(String fieldName, SolrParams params) Return aFragmenterappropriate for this field. If a fragmenter has not been configured for this field, fall back to the configured default or the solr default (GapFragmenter).- Parameters:
- fieldName- The name of the field
- params- The params controlling Highlighting
- Returns:
- An appropriate Fragmenter.
 
 - 
getFragListBuilderprotected org.apache.lucene.search.vectorhighlight.FragListBuilder getFragListBuilder(String fieldName, SolrParams params) 
 - 
getFragmentsBuilderprotected org.apache.lucene.search.vectorhighlight.FragmentsBuilder getFragmentsBuilder(String fieldName, SolrParams params) 
 - 
getSolrFragmentsBuilderprotected SolrFragmentsBuilder getSolrFragmentsBuilder(String fieldName, SolrParams params) 
 - 
getBoundaryScannerprotected org.apache.lucene.search.vectorhighlight.BoundaryScanner getBoundaryScanner(String fieldName, SolrParams params) 
 - 
doHighlightingpublic NamedList<Object> doHighlighting(DocList docs, org.apache.lucene.search.Query query, SolrQueryRequest req, String[] defaultFields) throws IOException Generates a list of Highlighted query fragments for each item in a list of documents, or returns null if highlighting is disabled.- Specified by:
- doHighlightingin class- SolrHighlighter
- Parameters:
- docs- query results
- query- the query
- req- the current request
- defaultFields- default list of fields to summarize
- Returns:
- NamedList containing a NamedList for each document, which in turns contains sets (field, summary) pairs.
- Throws:
- IOException
 
 - 
doHighlightingOfFieldprotected Object doHighlightingOfField(SolrDocument doc, int docId, SchemaField schemaField, DefaultSolrHighlighter.FvhContainer fvhContainer, org.apache.lucene.search.Query query, org.apache.lucene.index.IndexReader reader, SolrQueryRequest req, SolrParams params) throws IOException - Throws:
- IOException
 
 - 
getDocPrefetchFieldNamesprotected Set<String> getDocPrefetchFieldNames(String[] hlFieldNames, SolrQueryRequest req) Returns the field names to be passed toSolrDocumentFetcher.solrDoc(int, SolrReturnFields). 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.
 - 
useFastVectorHighlighterprotected boolean useFastVectorHighlighter(SolrParams params, SchemaField schemaField) Determines if we should use the FastVectorHighlighter for this field.
 - 
doHighlightingByFastVectorHighlighterprotected Object doHighlightingByFastVectorHighlighter(SolrDocument doc, int docId, SchemaField schemaField, DefaultSolrHighlighter.FvhContainer fvhContainer, org.apache.lucene.index.IndexReader reader, SolrQueryRequest req) throws IOException Highlights and returns the highlight object for this field -- a String[] by default. Null if none.- Throws:
- IOException
 
 - 
doHighlightingByHighlighterprotected Object doHighlightingByHighlighter(SolrDocument doc, int docId, SchemaField schemaField, org.apache.lucene.search.Query query, org.apache.lucene.index.IndexReader reader, SolrQueryRequest req) throws IOException Highlights and returns the highlight object for this field -- a String[] by default. Null if none.- Throws:
- IOException
 
 - 
getFieldValuesprotected List<String> getFieldValues(SolrDocument doc, String fieldName, int maxValues, int maxCharsToAnalyze, SolrQueryRequest req) Fetches field values to highlight. If the field value should come from an atypical place (or another aliased field name, then a subclass could override to implement that.
 - 
getResponseForFragmentsprotected Object getResponseForFragments(List<org.apache.lucene.search.highlight.TextFragment> frags, SolrQueryRequest req) Given the fragments, return the result to be put in the fieldNamedList. This is an extension point to allow adding other metadata like the absolute offsets or scores.
 - 
alternateFieldprotected Object alternateField(SolrDocument doc, int docId, String fieldName, DefaultSolrHighlighter.FvhContainer fvhContainer, org.apache.lucene.search.Query query, org.apache.lucene.index.IndexReader reader, SolrQueryRequest req) throws IOException Returns the alternate highlight object for this field -- a String[] by default. Null if none.- Throws:
- IOException
 
 - 
createAnalyzerTStreamprotected org.apache.lucene.analysis.TokenStream createAnalyzerTStream(SchemaField schemaField, String docText) throws IOException - Throws:
- IOException
 
 
- 
 
-