Package com.lucidworks.indexing.api
Interface IndexStage<T extends IndexStageConfig>
-
- Type Parameters:
T- index stage configuration class
- All Known Implementing Classes:
IndexStageBase
public interface IndexStage<T extends IndexStageConfig>Fusion index pipeline stage. Custom index stages must implement this interface to be discovered and called by Fusion. Example of custom index stage class:@Stage(type = "myStage", configClass = MyStageConfig.class) public class MyStage implements IndexStage<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 index stage instances at the same time.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidinit(T config, Fusion fusion)Stage initialization callback.default Documentprocess(Document document, Context context)Process single document.default voidprocess(Document document, Context context, java.util.function.Consumer<Document> output)Process single document.
-
-
-
Method Detail
-
init
void init(T config, Fusion fusion)
Stage initialization callback. This method will be called by Fusion when index stage instance is created and before 'process' method is called. Stage configuration will be passed by Fusion asIndexStageConfiginstance. AdditionallyFusioninterface instance will be passed to allow calling Fusion API from the index stage.- Parameters:
config- index pipeline stage configurationfusion- Fusion API instance
-
process
default Document process(Document document, Context context)
Process single document. This method is called for each document passing through index pipeline. Implement this method to perform processing of singleDocumentinstance that results in either 1 or 0 documents being emitted. Return null to drop document from the pipeline. This method is a convenience and will not be called ifprocess(Document, Context, Consumer)implementation is overridden. Default implementation is NOOP if not implemented. Note that this method implementation must be thread-safe as it can be invoked concurrently by multiple threads.- Parameters:
document- document going through index pipelinecontext- index pipeline context- Returns:
- processed document or null to drop document from the pipeline
-
process
default void process(Document document, Context context, java.util.function.Consumer<Document> output)
Process single document. This method is called for each document passing through index pipeline. Implement this method to perform processing of singleDocumentinstance that results in arbitrary number of documents being emitted. Calloutput.accept(document)for each document you want to emit as a result of processing. Note that after sending a document instance to the output, its state may be changed by subsequent stages, therefore it is strongly advised to discard the document instance immediately after emitting it. Passingnulltooutputconsumer will causeIllegalArgumentException. Overriding the default implementation of this method will result inprocess(Document, Context)to not be called. Default implementation is to callprocess(Document, Context)method. Note that this method implementation must be thread-safe as it can be invoked concurrently by multiple threads.- Parameters:
document- document going through index pipelinecontext- index pipeline contextoutput- consumer for documents emitted as the result of processing
-
-