Package com.lucidworks.querying.api
Interface QueryStage<T extends QueryStageConfig>
- Type Parameters:
- T- query stage configuration class
- All Known Implementing Classes:
- QueryStageBase
public interface QueryStage<T extends QueryStageConfig>
Fusion query pipeline stage. Custom query stages must implement this interface to be discovered and called
 by Fusion.
 Example of custom query stage class:
 
 @Stage(type = "myStage", configClass = MyStageConfig.class)
 public class MyStage implements QueryStage<MyStageConfig> {
   @Override
   public void init(MyStageConfig config, Fusion fusion) {
     // stage initialization logic
   }
   @Override
   public Document process(Document document, Context context) {
     // document processing logic
   }
 
 Implementations of this class must be stateless. Fusion can create and use multiple query stage instances
 at the same time.- 
Method SummaryModifier and TypeMethodDescriptionvoidStage initialization callback.default DslQueryRequestResponseprocess(DslQueryRequestResponse dslQueryRequestResponse, Context context) Process a single dslQueryRequestResponse.default voidprocess(DslQueryRequestResponse dslQueryRequestResponse, Context context, Consumer<DslQueryRequestResponse> output) Process single dslQueryRequestResponse.default QueryRequestResponseprocess(QueryRequestResponse queryRequestResponse, Context context) Process a single queryRequestResponse.default voidprocess(QueryRequestResponse queryRequestResponse, Context context, Consumer<QueryRequestResponse> output) Process single queryRequestResponse.
- 
Method Details- 
initStage initialization callback. This method will be called by Fusion when query stage instance is created and before 'process' method is called. Stage configuration will be passed by Fusion asQueryStageConfiginstance. AdditionallyFusioninterface instance will be passed to allow calling Fusion API from the query stage.- Parameters:
- config- query pipeline stage configuration
- fusion- Fusion API instance
 
- 
processdefault DslQueryRequestResponse process(DslQueryRequestResponse dslQueryRequestResponse, Context context) Process a single dslQueryRequestResponse. This method is called for each dslQueryRequestResponse passing through a query pipeline. Implement this method to perform processing of a singleDslQueryRequestResponseinstance that results in either 1 or 0 dslQueryRequestResponses being emitted. Return null to drop query from the pipeline. Note that this method implementation must be thread-safe as it can be invoked concurrently by multiple threads.- Parameters:
- dslQueryRequestResponse- dslQueryRequestResponse going through query pipeline
- context- query pipeline context
- Returns:
- processed query or null to drop query from the pipeline
 
- 
processdefault void process(DslQueryRequestResponse dslQueryRequestResponse, Context context, Consumer<DslQueryRequestResponse> output) Process single dslQueryRequestResponse. This method is called for each dslQueryRequestResponse passing through a query pipeline. Implement this method to perform processing of singleDslQueryRequestResponseinstance that results in an arbitrary number of dslQueryRequestResponses being emitted. Calloutput.accept(dslQueryRequestResponse)for each dslQueryRequestResponse you want to emit as a result of processing. Note that after sending a dslQueryRequestResponse instance to the output, its state may be changed by subsequent stages, therefore it is strongly advised to discard the dslQueryRequestResponse instance immediately after emitting it. Passingnulltooutputconsumer will causeIllegalArgumentException. Overriding the default implementation of this method will result inprocess(DslQueryRequestResponse, Context)to not be called. Default implementation is to callprocess(DslQueryRequestResponse, Context)method. Note that this method implementation must be thread-safe as it can be invoked concurrently by multiple threads.- Parameters:
- dslQueryRequestResponse- dslQueryRequestResponse going through query pipeline
- context- query pipeline context
- output- consumer for queryRequestResponses emitted as the result of processing
 
- 
processProcess a single queryRequestResponse. This method is called for each queryRequestResponse passing through a query pipeline. Implement this method to perform processing of a singleQueryRequestResponseinstance that results in either 1 or 0 queryRequestResponses being emitted. Return null to drop query from the pipeline. Note that this method implementation must be thread-safe as it can be invoked concurrently by multiple threads.- Parameters:
- queryRequestResponse- queryRequestResponse going through query pipeline
- context- query pipeline context
- Returns:
- processed query or null to drop query from the pipeline
 
- 
processdefault void process(QueryRequestResponse queryRequestResponse, Context context, Consumer<QueryRequestResponse> output) Process single queryRequestResponse. This method is called for each queryRequestResponse passing through index pipeline. Implement this method to perform processing of singleQueryRequestResponseinstance that results in arbitrary number of queryRequestResponses being emitted. Calloutput.accept(queryRequestResponse)for each queryRequestResponse you want to emit as a result of processing. Note that after sending a queryRequestResponse instance to the output, its state may be changed by subsequent stages, therefore it is strongly advised to discard the queryRequestResponse instance immediately after emitting it. Passingnulltooutputconsumer will causeIllegalArgumentException. Overriding the default implementation of this method will result inprocess(QueryRequestResponse, Context)to not be called. Default implementation is to callprocess(QueryRequestResponse, Context)method. Note that this method implementation must be thread-safe as it can be invoked concurrently by multiple threads.- Parameters:
- queryRequestResponse- queryRequestResponse going through query pipeline
- context- query pipeline context
- output- consumer for queryRequestResponses emitted as the result of processing
 
 
-