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 org.apache.solr.common.util.NamedList<?>
initParams
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
solrMetricsContext, 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 descriptionvoid
inform(SolrCore core)
void
init(org.apache.solr.common.util.NamedList<?> args)
init
will be called just once, immediately after creation.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, getName, getSolrMetricsContext, 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.metrics.SolrMetricProducer
close, getSolrMetricsContext
-
-
-
-
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 org.apache.solr.common.util.NamedList<?> initParams
-
suggesters
protected Map<String,SolrSuggester> suggesters
Key is the dictionary name used in SolrConfig, value is the correspondingSolrSuggester
-
-
Method Detail
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Description copied from interface:NamedListInitializedPlugin
init
will 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:
init
in interfaceNamedListInitializedPlugin
- Parameters:
args
- non-null list of initialization parameters (may be empty)
-
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
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, String scope)
Description copied from interface:SolrMetricProducer
Initialize metrics specific to this producer.- Specified by:
initializeMetrics
in interfaceSolrMetricProducer
- Overrides:
initializeMetrics
in classSearchComponent
- 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 object.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
-
-