Class SuggestComponent
- java.lang.Object
-
- org.apache.solr.handler.component.SearchComponent
-
- org.apache.solr.handler.component.SuggestComponent
-
- All Implemented Interfaces:
AutoCloseable,org.apache.lucene.util.Accountable,SolrInfoBean,SolrMetricProducer,SuggesterParams,NamedListInitializedPlugin,SolrCoreAware
public class SuggestComponent extends SearchComponent implements SolrCoreAware, SuggesterParams, org.apache.lucene.util.Accountable, SolrMetricProducer
SuggestComponent: interacts with multipleSolrSuggesterto serve up suggestions Responsible for routing commands and queries to the appropriateSolrSuggesterand for initializing them as specified by SolrConfig
-
-
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_NAMEName used to identify whether the user query concerns this componentprotected NamedListinitParamsprotected SolrMetricsContextmetricsContextprotected Map<String,SolrSuggester>suggestersKey is the dictionary name used in SolrConfig, value is the correspondingSolrSuggester-
Fields inherited from class org.apache.solr.handler.component.SearchComponent
metricNames, registry, standard_components
-
Fields inherited from interface org.apache.solr.spelling.suggest.SuggesterParams
SUGGEST_ALL_TERMS_REQUIRED, SUGGEST_BUILD, SUGGEST_BUILD_ALL, SUGGEST_CONTEXT_FILTER_QUERY, SUGGEST_COUNT, SUGGEST_DICT, SUGGEST_HIGHLIGHT, SUGGEST_PREFIX, SUGGEST_Q, SUGGEST_RELOAD, SUGGEST_RELOAD_ALL
-
-
Constructor Summary
Constructors Constructor Description SuggestComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intdistributedProcess(ResponseBuilder rb)Dispatch shard request inSTAGE_EXECUTE_QUERYstagevoidfinishStage(ResponseBuilder rb)Used in Distributed Search, merges the suggestion results from every shardCollection<org.apache.lucene.util.Accountable>getChildResources()StringgetDescription()Simple one or two line descriptionSolrMetricsContextgetSolrMetricsContext()Implementing classes should override this method to provide the context obtained inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)to ensure proper cleanup of metrics at the end of the life-cycle of this component.voidinform(SolrCore core)voidinit(NamedList args)voidinitializeMetrics(SolrMetricsContext parentContext, String scope)Initialize metrics specific to this producer.voidprepare(ResponseBuilder rb)Responsible for issuing build and rebuild command to the specifiedSolrSuggestervoidprocess(ResponseBuilder rb)Responsible for using the specified suggester to get the suggestions for the query and write the resultslongramBytesUsed()-
Methods inherited from class org.apache.solr.handler.component.SearchComponent
getCategory, getMetricNames, getMetricRegistry, getName, handleResponses, modifyRequest, 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
-
Methods inherited from interface org.apache.solr.metrics.SolrMetricProducer
close, initializeMetrics
-
-
-
-
Field Detail
-
COMPONENT_NAME
public static final String COMPONENT_NAME
Name used to identify whether the user query concerns this component- See Also:
- Constant Field Values
-
initParams
protected NamedList initParams
-
metricsContext
protected SolrMetricsContext metricsContext
-
suggesters
protected Map<String,SolrSuggester> suggesters
Key is the dictionary name used in SolrConfig, value is the correspondingSolrSuggester
-
-
Method Detail
-
init
public void init(NamedList args)
- Specified by:
initin interfaceNamedListInitializedPlugin- Overrides:
initin classSearchComponent
-
inform
public void inform(SolrCore core)
- Specified by:
informin interfaceSolrCoreAware
-
prepare
public void prepare(ResponseBuilder rb) throws IOException
Responsible for issuing build and rebuild command to the specifiedSolrSuggester- Specified by:
preparein classSearchComponent- Parameters:
rb- TheResponseBuilder- Throws:
IOException- If there is a low-level I/O error.
-
distributedProcess
public int distributedProcess(ResponseBuilder rb)
Dispatch shard request inSTAGE_EXECUTE_QUERYstage- Overrides:
distributedProcessin classSearchComponent- Returns:
- the next stage for this component
-
process
public void process(ResponseBuilder rb) throws IOException
Responsible for using the specified suggester to get the suggestions for the query and write the results- Specified by:
processin classSearchComponent- Parameters:
rb- TheResponseBuilder- Throws:
IOException- If there is a low-level I/O error.
-
finishStage
public void finishStage(ResponseBuilder rb)
Used in Distributed Search, merges the suggestion results from every shard- Overrides:
finishStagein classSearchComponent
-
getDescription
public String getDescription()
Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
getDescriptionin interfaceSolrInfoBean- Specified by:
getDescriptionin classSearchComponent
-
getSolrMetricsContext
public SolrMetricsContext getSolrMetricsContext()
Description copied from interface:SolrMetricProducerImplementing classes should override this method to provide the context obtained inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)to ensure proper cleanup of metrics at the end of the life-cycle of this component.- Specified by:
getSolrMetricsContextin interfaceSolrMetricProducer
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, String scope)
Description copied from interface:SolrMetricProducerInitialize metrics specific to this producer.- Specified by:
initializeMetricsin interfaceSolrMetricProducer- Parameters:
parentContext- parent metrics context. If this component has the same life-cycle as the parent it can simply use the parent context, otherwise it should obtain a child context usingSolrMetricsContext.getChildContext(Object)passingthisas the child.scope- component scope
-
ramBytesUsed
public long ramBytesUsed()
- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
getChildResources
public Collection<org.apache.lucene.util.Accountable> getChildResources()
- Specified by:
getChildResourcesin interfaceorg.apache.lucene.util.Accountable
-
-