org.apache.solr.highlight
Class PostingsSolrHighlighter

java.lang.Object
  extended by org.apache.solr.highlight.SolrHighlighter
      extended by org.apache.solr.highlight.PostingsSolrHighlighter
All Implemented Interfaces:
PluginInfoInitialized

public class PostingsSolrHighlighter
extends SolrHighlighter
implements PluginInfoInitialized

Highlighter impl that uses PostingsHighlighter

Example configuration:

   <searchComponent class="solr.HighlightComponent" name="highlight">
     <highlighting class="org.apache.solr.highlight.PostingsSolrHighlighter"
                      preTag="&lt;em&gt;"
                      postTag="&lt;/em&gt;"
                      ellipsis="... "
                      maxLength=10000/>
   </searchComponent>
 

Notes:

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
protected  PostingsHighlighter highlighter
           
 
Fields inherited from class org.apache.solr.highlight.SolrHighlighter
boundaryScanners, encoders, formatters, fragListBuilders, fragmenters, fragmentsBuilders, log
 
Constructor Summary
PostingsSolrHighlighter()
           
 
Method Summary
 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  String[] getUniqueKeys(SolrIndexSearcher searcher, TopDocs topDocs)
          Retrieves the unique keys for the topdocs to key the results
 void init(PluginInfo info)
           
 void initalize(SolrConfig config)
           
protected  TopDocs toTopDocs(DocList docs)
          Converts solr's DocList to a lucene TopDocs
 
Methods inherited from class org.apache.solr.highlight.SolrHighlighter
emptyArray, getHighlightFields, isHighlightingEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

highlighter

protected PostingsHighlighter highlighter
Constructor Detail

PostingsSolrHighlighter

public PostingsSolrHighlighter()
Method Detail

initalize

public void initalize(SolrConfig config)
Specified by:
initalize in class SolrHighlighter

init

public void init(PluginInfo info)
Specified by:
init in interface PluginInfoInitialized

doHighlighting

public NamedList<Object> doHighlighting(DocList docs,
                                        Query query,
                                        SolrQueryRequest req,
                                        String[] defaultFields)
                                 throws IOException
Description copied from class: SolrHighlighter
Generates a list of Highlighted query fragments for each item in a list of documents, or returns null if highlighting is disabled.

Specified by:
doHighlighting in 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

encodeSnippets

protected NamedList<Object> encodeSnippets(String[] keys,
                                           String[] fieldNames,
                                           Map<String,String[]> snippets)
Encodes the resulting snippets into a namedlist

Parameters:
keys - the document unique keys
fieldNames - field names to highlight in the order
snippets - map from field name to snippet array for the docs
Returns:
encoded namedlist of summaries

toTopDocs

protected TopDocs toTopDocs(DocList docs)
Converts solr's DocList to a lucene TopDocs


getUniqueKeys

protected String[] getUniqueKeys(SolrIndexSearcher searcher,
                                 TopDocs topDocs)
                          throws IOException
Retrieves the unique keys for the topdocs to key the results

Throws:
IOException


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.