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 multiple
SolrSuggester to serve up suggestions
Responsible for routing commands and queries to the appropriate SolrSuggester 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
FieldsModifier and TypeFieldDescriptionstatic final StringName used to identify whether the user query concerns this componentprotected org.apache.solr.common.util.NamedList<?> protected Map<String, SolrSuggester> Key is the dictionary name used in SolrConfig, value is the correspondingSolrSuggesterFields inherited from class org.apache.solr.handler.component.SearchComponent
solrMetricsContext, standard_componentsFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLEFields 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.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 -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Implementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered.intDispatch shard request inSTAGE_EXECUTE_QUERYstagevoidUsed in Distributed Search, merges the suggestion results from every shardCollection<org.apache.lucene.util.Accountable> Simple one or two line descriptionvoidvoidinit(org.apache.solr.common.util.NamedList<?> args) initwill be called just once, immediately after creation.voidinitializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes) Implementation should initialize all metrics to aSolrMetricsContextRegistry/MeterProvider withAttributesas the common set of attributes that will be attached to every metric that is initialized for that class/componentvoidResponsible for issuing build and rebuild command to the specifiedSolrSuggestervoidResponsible for using the specified suggester to get the suggestions for the query and write the resultslongMethods inherited from class org.apache.solr.handler.component.SearchComponent
getCategory, getName, getSolrMetricsContext, handleResponses, modifyRequest, 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
getSolrMetricsContext
-
Field Details
-
COMPONENT_NAME
Name used to identify whether the user query concerns this component- See Also:
-
initParams
protected org.apache.solr.common.util.NamedList<?> initParams -
suggesters
Key is the dictionary name used in SolrConfig, value is the correspondingSolrSuggester
-
-
Constructor Details
-
SuggestComponent
public SuggestComponent()
-
-
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)
-
inform
- Specified by:
informin interfaceSolrCoreAware
-
prepare
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
Dispatch shard request inSTAGE_EXECUTE_QUERYstage- Overrides:
distributedProcessin classSearchComponent- Returns:
- the next stage for this component
-
process
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
Used in Distributed Search, merges the suggestion results from every shard- Overrides:
finishStagein classSearchComponent
-
getDescription
Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
getDescriptionin interfaceSolrInfoBean- Specified by:
getDescriptionin classSearchComponent
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes) Description copied from interface:SolrMetricProducerImplementation should initialize all metrics to aSolrMetricsContextRegistry/MeterProvider withAttributesas the common set of attributes that will be attached to every metric that is initialized for that class/component- Specified by:
initializeMetricsin interfaceSolrMetricProducer- Overrides:
initializeMetricsin classSearchComponent- Parameters:
parentContext- The registry that the component will initialize metrics toattributes- Base set of attributes that will be bound to all metrics for that component
-
ramBytesUsed
public long ramBytesUsed()- Specified by:
ramBytesUsedin interfaceorg.apache.lucene.util.Accountable
-
getChildResources
- Specified by:
getChildResourcesin interfaceorg.apache.lucene.util.Accountable
-
close
Description copied from interface:SolrMetricProducerImplementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered. This prevents obscure memory leaks.from: https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html While this interface method is declared to throw Exception, implementers are strongly encouraged to declare concrete implementations of the close method to throw more specific exceptions, or to throw no exception at all if the close operation cannot fail.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSolrMetricProducer- Throws:
IOException
-