Class SpellCheckComponent
java.lang.Object
org.apache.solr.handler.component.SearchComponent
org.apache.solr.handler.component.SpellCheckComponent
- All Implemented Interfaces:
AutoCloseable,org.apache.solr.common.params.SpellingParams,SolrInfoBean,SolrMetricProducer,NamedListInitializedPlugin,SolrCoreAware
public class SpellCheckComponent
extends SearchComponent
implements SolrCoreAware, org.apache.solr.common.params.SpellingParams
A SearchComponent implementation which provides support for spell checking and suggestions using
the Lucene contributed SpellChecker.
Refer to https://solr.apache.org/guide/solr/latest/query-guide/spell-checking.html 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
FieldsModifier and TypeFieldDescriptionstatic final StringBase name for all spell checker query parameters.static final booleanprotected org.apache.solr.common.util.NamedList<?> protected QueryConverterprotected Map<String, SolrSpellChecker> Key is the dictionary, value is the SpellChecker for that dictionary nameFields inherited from class org.apache.solr.handler.component.SearchComponent
solrMetricsContext, standard_componentsFields inherited from interface org.apache.solr.metrics.SolrMetricProducer
CATEGORY_ATTR, HANDLER_ATTR, NAME_ATTR, OPERATION_ATTR, PLUGIN_NAME_ATTR, RESULT_ATTR, TYPE_ATTRFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCollationsToResponse(org.apache.solr.common.params.SolrParams params, SpellingResult spellingResult, ResponseBuilder rb, String q, org.apache.solr.common.util.NamedList<Object> response, boolean suggestionsMayOverlap) voidCalled after all responses have been received for this stage.protected org.apache.solr.common.params.SolrParamsgetCustomParams(String dictionary, org.apache.solr.common.params.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 listSimple one or two line descriptiongetSpellChecker(String name) protected SolrSpellCheckergetSpellChecker(org.apache.solr.common.params.SolrParams params) voidvoidinit(org.apache.solr.common.util.NamedList<?> args) initwill be called just once, immediately after creation.voidmodifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) Called after another component adds a requestvoidPrepare the response.voidProcess the request for this componentprotected org.apache.solr.common.util.NamedList<Object> toNamedList(boolean shardRequest, SpellingResult spellingResult, String origQuery, boolean extendedResults) Methods inherited from class org.apache.solr.handler.component.SearchComponent
distributedProcess, getCategory, getName, getSolrMetricsContext, handleResponses, initializeMetrics, setNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.solr.metrics.SolrMetricProducer
close
-
Field Details
-
DEFAULT_ONLY_MORE_POPULAR
public static final boolean DEFAULT_ONLY_MORE_POPULAR- See Also:
-
COMPONENT_NAME
Base name for all spell checker query parameters. This name is also used to register this component with SearchHandler.- See Also:
-
initParams
protected org.apache.solr.common.util.NamedList<?> initParams -
spellCheckers
Key is the dictionary, value is the SpellChecker for that dictionary name -
queryConverter
-
-
Constructor Details
-
SpellCheckComponent
public SpellCheckComponent()
-
-
Method Details
-
init
public void init(org.apache.solr.common.util.NamedList<?> args) Description copied from interface:NamedListInitializedPlugininitwill be called just once, immediately after creation.Source of the initialization arguments will typically be solrconfig.xml, but will ultimately depends on the plugin itself
- Specified by:
initin interfaceNamedListInitializedPlugin- Parameters:
args- non-null list of initialization parameters (may be empty)
-
prepare
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
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(org.apache.solr.common.params.SolrParams params, SpellingResult spellingResult, ResponseBuilder rb, String q, org.apache.solr.common.util.NamedList<Object> response, boolean suggestionsMayOverlap) -
getCustomParams
protected org.apache.solr.common.params.SolrParams getCustomParams(String dictionary, org.apache.solr.common.params.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
Description copied from class:SearchComponentCalled after another component adds a request- Overrides:
modifyRequestin classSearchComponent
-
finishStage
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
-
getSpellChecker
- Returns:
- the spellchecker registered to a given name
-
toNamedList
protected org.apache.solr.common.util.NamedList<Object> toNamedList(boolean shardRequest, SpellingResult spellingResult, String origQuery, boolean extendedResults) -
inform
- Specified by:
informin interfaceSolrCoreAware
-
getSpellCheckers
-
getDescription
Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
getDescriptionin interfaceSolrInfoBean- Specified by:
getDescriptionin classSearchComponent
-