Class AsyncBuildSuggestComponent

  • All Implemented Interfaces:
    org.apache.lucene.util.Accountable, org.apache.solr.core.SolrInfoMBean, org.apache.solr.spelling.suggest.SuggesterParams, org.apache.solr.util.plugin.NamedListInitializedPlugin, org.apache.solr.util.plugin.SolrCoreAware

    public class AsyncBuildSuggestComponent
    extends org.apache.solr.handler.component.SearchComponent
    implements org.apache.solr.util.plugin.SolrCoreAware, org.apache.solr.spelling.suggest.SuggesterParams, org.apache.lucene.util.Accountable
    Originally taken from SuggestComponent and modified, this class provides a SearchComponent that builds SolrSuggester objects asynchronously to avoid blocking search requests or increasing startup time of the servlet container.
    See Also:
    SuggestComponent
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoMBean

        org.apache.solr.core.SolrInfoMBean.Category, org.apache.solr.core.SolrInfoMBean.Group
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String COMPONENT_NAME
      Name used to identify whether the user query concerns this component
      protected org.apache.solr.common.util.NamedList initParams  
      protected java.util.Map<java.lang.String,​org.alfresco.solr.component.AsyncBuildSuggestComponent.SuggesterCache> suggesters
      Key is the dictionary name used in SolrConfig, value is the corresponding SolrSuggester
      protected static TempFileWarningLogger tempFileWarningLogger  
      • Fields inherited from class org.apache.solr.handler.component.SearchComponent

        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
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int distributedProcess​(org.apache.solr.handler.component.ResponseBuilder rb)
      Dispatch shard request in STAGE_EXECUTE_QUERY stage
      void finishStage​(org.apache.solr.handler.component.ResponseBuilder rb)
      Used in Distributed Search, merges the suggestion results from every shard
      java.util.Collection<org.apache.lucene.util.Accountable> getChildResources()  
      java.lang.String getDescription()  
      java.lang.String getSource()  
      org.apache.solr.common.util.NamedList<java.lang.String> getStatistics()  
      void inform​(org.apache.solr.core.SolrCore core)  
      void init​(org.apache.solr.common.util.NamedList args)  
      void prepare​(org.apache.solr.handler.component.ResponseBuilder rb)
      Responsible for issuing build and rebload command to the specified SolrSuggester
      void process​(org.apache.solr.handler.component.ResponseBuilder rb)
      Responsible for using the specified suggester to get the suggestions for the query and write the results
      long ramBytesUsed()  
      • Methods inherited from class org.apache.solr.handler.component.SearchComponent

        getCategory, getDocs, getName, getVersion, handleResponses, modifyRequest, setName
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COMPONENT_NAME

        public static final java.lang.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 java.util.Map<java.lang.String,​org.alfresco.solr.component.AsyncBuildSuggestComponent.SuggesterCache> suggesters
        Key is the dictionary name used in SolrConfig, value is the corresponding SolrSuggester
    • Constructor Detail

      • AsyncBuildSuggestComponent

        public AsyncBuildSuggestComponent()
    • Method Detail

      • init

        public void init​(org.apache.solr.common.util.NamedList args)
        Specified by:
        init in interface org.apache.solr.util.plugin.NamedListInitializedPlugin
        Overrides:
        init in class org.apache.solr.handler.component.SearchComponent
      • inform

        public void inform​(org.apache.solr.core.SolrCore core)
        Specified by:
        inform in interface org.apache.solr.util.plugin.SolrCoreAware
      • prepare

        public void prepare​(org.apache.solr.handler.component.ResponseBuilder rb)
                     throws java.io.IOException
        Responsible for issuing build and rebload command to the specified SolrSuggester
        Specified by:
        prepare in class org.apache.solr.handler.component.SearchComponent
        Throws:
        java.io.IOException
      • distributedProcess

        public int distributedProcess​(org.apache.solr.handler.component.ResponseBuilder rb)
        Dispatch shard request in STAGE_EXECUTE_QUERY stage
        Overrides:
        distributedProcess in class org.apache.solr.handler.component.SearchComponent
      • process

        public void process​(org.apache.solr.handler.component.ResponseBuilder rb)
                     throws java.io.IOException
        Responsible for using the specified suggester to get the suggestions for the query and write the results
        Specified by:
        process in class org.apache.solr.handler.component.SearchComponent
        Throws:
        java.io.IOException
      • finishStage

        public void finishStage​(org.apache.solr.handler.component.ResponseBuilder rb)
        Used in Distributed Search, merges the suggestion results from every shard
        Overrides:
        finishStage in class org.apache.solr.handler.component.SearchComponent
      • getDescription

        public java.lang.String getDescription()
        Specified by:
        getDescription in interface org.apache.solr.core.SolrInfoMBean
        Specified by:
        getDescription in class org.apache.solr.handler.component.SearchComponent
      • getSource

        public java.lang.String getSource()
        Specified by:
        getSource in interface org.apache.solr.core.SolrInfoMBean
        Overrides:
        getSource in class org.apache.solr.handler.component.SearchComponent
      • getStatistics

        public org.apache.solr.common.util.NamedList<java.lang.String> getStatistics()
        Specified by:
        getStatistics in interface org.apache.solr.core.SolrInfoMBean
        Overrides:
        getStatistics in class org.apache.solr.handler.component.SearchComponent
      • ramBytesUsed

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

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