Class SpellCheckComponent
- java.lang.Object
-
- org.apache.solr.handler.component.SearchComponent
-
- org.apache.solr.handler.component.SpellCheckComponent
-
- All Implemented Interfaces:
SpellingParams,SolrInfoBean,NamedListInitializedPlugin,SolrCoreAware
public class SpellCheckComponent extends SearchComponent implements SolrCoreAware, SpellingParams
A SearchComponent implementation which provides support for spell checking and suggestions using the Lucene contributed SpellChecker.Refer to http://wiki.apache.org/solr/SpellCheckComponent for more details
- Since:
- solr 1.3
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOMPONENT_NAMEBase name for all spell checker query parameters.static booleanDEFAULT_ONLY_MORE_POPULARprotected NamedListinitParamsprotected QueryConverterqueryConverterprotected Map<String,SolrSpellChecker>spellCheckersKey is the dictionary, value is the SpellChecker for that dictionary name-
Fields inherited from class org.apache.solr.handler.component.SearchComponent
metricNames, registry, standard_components
-
Fields inherited from interface org.apache.solr.common.params.SpellingParams
SPELLCHECK_ACCURACY, SPELLCHECK_ALTERNATIVE_TERM_COUNT, SPELLCHECK_BUILD, SPELLCHECK_COLLATE, SPELLCHECK_COLLATE_EXTENDED_RESULTS, SPELLCHECK_COLLATE_MAX_COLLECT_DOCS, SPELLCHECK_COLLATE_PARAM_OVERRIDE, SPELLCHECK_COUNT, SPELLCHECK_DICT, SPELLCHECK_EXTENDED_RESULTS, SPELLCHECK_MAX_COLLATION_EVALUATIONS, SPELLCHECK_MAX_COLLATION_TRIES, SPELLCHECK_MAX_COLLATIONS, SPELLCHECK_MAX_RESULTS_FOR_SUGGEST, SPELLCHECK_MAX_RESULTS_FOR_SUGGEST_FQ, SPELLCHECK_ONLY_MORE_POPULAR, SPELLCHECK_PREFIX, SPELLCHECK_Q, SPELLCHECK_RELOAD
-
-
Constructor Summary
Constructors Constructor Description SpellCheckComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCollationsToResponse(SolrParams params, SpellingResult spellingResult, ResponseBuilder rb, String q, NamedList response, boolean suggestionsMayOverlap)voidfinishStage(ResponseBuilder rb)Called after all responses have been received for this stage.SolrInfoBean.CategorygetCategory()Category of this componentprotected SolrParamsgetCustomParams(String dictionary, SolrParams params)For every param that is of the form "spellcheck.[dictionary name].XXXX=YYYY, add XXXX=YYYY as a param to the custom param listStringgetDescription()Simple one or two line descriptionSolrSpellCheckergetSpellChecker(String name)protected SolrSpellCheckergetSpellChecker(SolrParams params)Map<String,SolrSpellChecker>getSpellCheckers()voidinform(SolrCore core)voidinit(NamedList args)voidmodifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq)Called after another component adds a requestvoidprepare(ResponseBuilder rb)Prepare the response.voidprocess(ResponseBuilder rb)Process the request for this componentprotected NamedListtoNamedList(boolean shardRequest, SpellingResult spellingResult, String origQuery, boolean extendedResults)-
Methods inherited from class org.apache.solr.handler.component.SearchComponent
distributedProcess, getMetricNames, getMetricRegistry, getName, handleResponses, setName
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.solr.core.SolrInfoBean
getMetricsSnapshot, registerMetricName
-
-
-
-
Field Detail
-
DEFAULT_ONLY_MORE_POPULAR
public static final boolean DEFAULT_ONLY_MORE_POPULAR
- See Also:
- Constant Field Values
-
COMPONENT_NAME
public static final String COMPONENT_NAME
Base name for all spell checker query parameters. This name is also used to register this component with SearchHandler.- See Also:
- Constant Field Values
-
initParams
protected NamedList initParams
-
spellCheckers
protected Map<String,SolrSpellChecker> spellCheckers
Key is the dictionary, value is the SpellChecker for that dictionary name
-
queryConverter
protected QueryConverter queryConverter
-
-
Method Detail
-
init
public void init(NamedList args)
- Specified by:
initin interfaceNamedListInitializedPlugin- Overrides:
initin classSearchComponent
-
prepare
public void prepare(ResponseBuilder rb) throws IOException
Description copied from class:SearchComponentPrepare the response. Guaranteed to be called before any SearchComponentSearchComponent.process(org.apache.solr.handler.component.ResponseBuilder)method. Called for every incoming request. The place to do initialization that is request dependent.- Specified by:
preparein classSearchComponent- Parameters:
rb- TheResponseBuilder- Throws:
IOException- If there is a low-level I/O error.
-
process
public void process(ResponseBuilder rb) throws IOException
Description copied from class:SearchComponentProcess the request for this component- Specified by:
processin classSearchComponent- Parameters:
rb- TheResponseBuilder- Throws:
IOException- If there is a low-level I/O error.
-
addCollationsToResponse
protected void addCollationsToResponse(SolrParams params, SpellingResult spellingResult, ResponseBuilder rb, String q, NamedList response, boolean suggestionsMayOverlap)
-
getCustomParams
protected SolrParams getCustomParams(String dictionary, SolrParams params)
For every param that is of the form "spellcheck.[dictionary name].XXXX=YYYY, add XXXX=YYYY as a param to the custom param list- Parameters:
params- The original SolrParams- Returns:
- The new Params
-
modifyRequest
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq)
Description copied from class:SearchComponentCalled after another component adds a request- Overrides:
modifyRequestin classSearchComponent
-
finishStage
public void finishStage(ResponseBuilder rb)
Description copied from class:SearchComponentCalled after all responses have been received for this stage. Useful when different requests are sent to each shard.- Overrides:
finishStagein classSearchComponent
-
getSpellChecker
protected SolrSpellChecker getSpellChecker(SolrParams params)
-
getSpellChecker
public SolrSpellChecker getSpellChecker(String name)
- Returns:
- the spellchecker registered to a given name
-
toNamedList
protected NamedList toNamedList(boolean shardRequest, SpellingResult spellingResult, String origQuery, boolean extendedResults)
-
inform
public void inform(SolrCore core)
- Specified by:
informin interfaceSolrCoreAware
-
getSpellCheckers
public Map<String,SolrSpellChecker> getSpellCheckers()
-
getDescription
public String getDescription()
Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
getDescriptionin interfaceSolrInfoBean- Specified by:
getDescriptionin classSearchComponent
-
getCategory
public SolrInfoBean.Category getCategory()
Description copied from interface:SolrInfoBeanCategory of this component- Specified by:
getCategoryin interfaceSolrInfoBean- Overrides:
getCategoryin classSearchComponent
-
-