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
  • Field Details

    • COMPONENT_NAME

      public static final String 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

      protected Map<String,SolrSuggester> suggesters
      Key is the dictionary name used in SolrConfig, value is the corresponding SolrSuggester
  • Constructor Details

    • SuggestComponent

      public SuggestComponent()
  • Method Details

    • 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 interface NamedListInitializedPlugin
      Parameters:
      args - non-null list of initialization parameters (may be empty)
    • inform

      public void inform(SolrCore core)
      Specified by:
      inform in interface SolrCoreAware
    • prepare

      public void prepare(ResponseBuilder rb) throws IOException
      Responsible for issuing build and rebuild command to the specified SolrSuggester
      Specified by:
      prepare in class SearchComponent
      Parameters:
      rb - The ResponseBuilder
      Throws:
      IOException - If there is a low-level I/O error.
    • distributedProcess

      public int distributedProcess(ResponseBuilder rb)
      Dispatch shard request in STAGE_EXECUTE_QUERY stage
      Overrides:
      distributedProcess in class SearchComponent
      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 class SearchComponent
      Parameters:
      rb - The ResponseBuilder
      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 class SearchComponent
    • getDescription

      public String getDescription()
      Description copied from interface: SolrInfoBean
      Simple one or two line description
      Specified by:
      getDescription in interface SolrInfoBean
      Specified by:
      getDescription in class SearchComponent
    • initializeMetrics

      public void initializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes)
      Description copied from interface: SolrMetricProducer
      Implementation should initialize all metrics to a SolrMetricsContext Registry/MeterProvider with Attributes as the common set of attributes that will be attached to every metric that is initialized for that class/component
      Specified by:
      initializeMetrics in interface SolrMetricProducer
      Overrides:
      initializeMetrics in class SearchComponent
      Parameters:
      parentContext - The registry that the component will initialize metrics to
      attributes - Base set of attributes that will be bound to all metrics for that component
    • ramBytesUsed

      public long ramBytesUsed()
      Specified by:
      ramBytesUsed in interface org.apache.lucene.util.Accountable
    • getChildResources

      public Collection<org.apache.lucene.util.Accountable> getChildResources()
      Specified by:
      getChildResources in interface org.apache.lucene.util.Accountable
    • close

      public void close() throws IOException
      Description copied from interface: SolrMetricProducer
      Implementations should always call SolrMetricProducer.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:
      close in interface AutoCloseable
      Specified by:
      close in interface SolrMetricProducer
      Throws:
      IOException