Class SearchComponent
- java.lang.Object
-
- org.apache.solr.handler.component.SearchComponent
-
- All Implemented Interfaces:
AutoCloseable
,SolrInfoBean
,SolrMetricProducer
,NamedListInitializedPlugin
- Direct Known Subclasses:
ActiveTasksListComponent
,DebugComponent
,ExpandComponent
,FacetComponent
,FacetModule
,HighlightComponent
,MoreLikeThisComponent
,PhrasesIdentificationComponent
,QueryCancellationComponent
,QueryComponent
,QueryElevationComponent
,RealTimeGetComponent
,ResponseLogComponent
,SpellCheckComponent
,StatsComponent
,SuggestComponent
,TermsComponent
,TermVectorComponent
public abstract class SearchComponent extends Object implements SolrInfoBean, NamedListInitializedPlugin
TODO!- Since:
- solr 1.3
-
-
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 protected SolrMetricsContext
solrMetricsContext
static Map<String,Class<? extends SearchComponent>>
standard_components
-
Constructor Summary
Constructors Constructor Description SearchComponent()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
distributedProcess(ResponseBuilder rb)
Process for a distributed search.void
finishStage(ResponseBuilder rb)
Called after all responses have been received for this stage.SolrInfoBean.Category
getCategory()
Category of this componentabstract String
getDescription()
Simple one or two line descriptionString
getName()
Simple common usage name, e.g.SolrMetricsContext
getSolrMetricsContext()
Implementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)
to ensure proper cleanup of metrics at the end of the life-cycle of this component.void
handleResponses(ResponseBuilder rb, ShardRequest sreq)
Called after all responses for a single request were receivedvoid
initializeMetrics(SolrMetricsContext parentContext, String scope)
Initialize metrics specific to this producer.void
modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq)
Called after another component adds a requestabstract void
prepare(ResponseBuilder rb)
Prepare the response.abstract void
process(ResponseBuilder rb)
Process the request for this componentvoid
setName(String name)
Sets the name of the SearchComponent.-
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.util.plugin.NamedListInitializedPlugin
init
-
Methods inherited from interface org.apache.solr.metrics.SolrMetricProducer
close
-
-
-
-
Field Detail
-
solrMetricsContext
protected SolrMetricsContext solrMetricsContext
-
standard_components
public static final Map<String,Class<? extends SearchComponent>> standard_components
-
-
Method Detail
-
prepare
public abstract void prepare(ResponseBuilder rb) throws IOException
Prepare the response. Guaranteed to be called before any SearchComponentprocess(org.apache.solr.handler.component.ResponseBuilder)
method. Called for every incoming request.The place to do initialization that is request dependent.
- Parameters:
rb
- TheResponseBuilder
- Throws:
IOException
- If there is a low-level I/O error.
-
process
public abstract void process(ResponseBuilder rb) throws IOException
Process the request for this component- Parameters:
rb
- TheResponseBuilder
- Throws:
IOException
- If there is a low-level I/O error.
-
distributedProcess
public int distributedProcess(ResponseBuilder rb) throws IOException
Process for a distributed search.- Returns:
- the next stage for this component
- Throws:
IOException
-
modifyRequest
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq)
Called after another component adds a request
-
handleResponses
public void handleResponses(ResponseBuilder rb, ShardRequest sreq)
Called after all responses for a single request were received
-
finishStage
public void finishStage(ResponseBuilder rb)
Called after all responses have been received for this stage. Useful when different requests are sent to each shard.
-
setName
public void setName(String name)
Sets the name of the SearchComponent. The name of the component is usually the name defined for it in the configuration.
-
getName
public String getName()
Description copied from interface:SolrInfoBean
Simple common usage name, e.g. BasicQueryHandler, or fully qualified class name.- Specified by:
getName
in interfaceSolrInfoBean
-
getDescription
public abstract String getDescription()
Description copied from interface:SolrInfoBean
Simple one or two line description- Specified by:
getDescription
in interfaceSolrInfoBean
-
getCategory
public SolrInfoBean.Category getCategory()
Description copied from interface:SolrInfoBean
Category of this component- Specified by:
getCategory
in interfaceSolrInfoBean
-
getSolrMetricsContext
public SolrMetricsContext getSolrMetricsContext()
Description copied from interface:SolrMetricProducer
Implementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, String)
to ensure proper cleanup of metrics at the end of the life-cycle of this component. This should be the child context if one was created, or null if the parent context was used.- 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 object.scope
- component scope
-
-