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 multipleSolrSuggester
to serve up suggestions Responsible for routing commands and queries to the appropriateSolrSuggester
and 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 String
COMPONENT_NAME
Name used to identify whether the user query concerns this componentprotected NamedList
initParams
protected SolrMetricsContext
metricsContext
protected Map<String,SolrSuggester>
suggesters
Key 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 int
distributedProcess(ResponseBuilder rb)
Dispatch shard request inSTAGE_EXECUTE_QUERY
stagevoid
finishStage(ResponseBuilder rb)
Used in Distributed Search, merges the suggestion results from every shardCollection<org.apache.lucene.util.Accountable>
getChildResources()
String
getDescription()
Simple one or two line descriptionSolrMetricsContext
getSolrMetricsContext()
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.void
inform(SolrCore core)
void
init(NamedList args)
void
initializeMetrics(SolrMetricsContext parentContext, String scope)
Initialize metrics specific to this producer.void
prepare(ResponseBuilder rb)
Responsible for issuing build and rebuild command to the specifiedSolrSuggester
void
process(ResponseBuilder rb)
Responsible for using the specified suggester to get the suggestions for the query and write the resultslong
ramBytesUsed()
-
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:
init
in interfaceNamedListInitializedPlugin
- Overrides:
init
in classSearchComponent
-
inform
public void inform(SolrCore core)
- Specified by:
inform
in interfaceSolrCoreAware
-
prepare
public void prepare(ResponseBuilder rb) throws IOException
Responsible for issuing build and rebuild command to the specifiedSolrSuggester
- Specified by:
prepare
in 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_QUERY
stage- Overrides:
distributedProcess
in 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:
process
in 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:
finishStage
in classSearchComponent
-
getDescription
public String getDescription()
Description copied from interface:SolrInfoBean
Simple one or two line description- Specified by:
getDescription
in interfaceSolrInfoBean
- Specified by:
getDescription
in classSearchComponent
-
getSolrMetricsContext
public SolrMetricsContext getSolrMetricsContext()
Description copied from interface:SolrMetricProducer
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.- Specified by:
getSolrMetricsContext
in interfaceSolrMetricProducer
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, String scope)
Description copied from interface:SolrMetricProducer
Initialize metrics specific to this producer.- Specified by:
initializeMetrics
in 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)
passingthis
as the child.scope
- component scope
-
ramBytesUsed
public long ramBytesUsed()
- Specified by:
ramBytesUsed
in interfaceorg.apache.lucene.util.Accountable
-
getChildResources
public Collection<org.apache.lucene.util.Accountable> getChildResources()
- Specified by:
getChildResources
in interfaceorg.apache.lucene.util.Accountable
-
-