query-stage-plugin-sdk
directory.
.zip
file that contains one or more query stage implementations. The file contains .jar
files for stage definitions and additional dependencies. It also contains a manifest file that holds the metadata Fusion uses to run the plugin.
For build and deployment instructions, see
Build and Deploy A Query Stage Plugin.
Build and Deploy A Query Stage Plugin
.zip
file (with required manifest file) inside the build/libs
folder.Stages
list in the Fusion Query Pipelines UI.com.lucidworks.querying.api.QueryStage
class is the basic contract for defining a plugin query stage.
A plugin stage class must:
com.lucidworks.querying.api.QueryStage
interface.com.lucidworks.querying.api.Stage
annotation.com.lucidworks.querying.api.QueryStageBase
,
which already contains initialization logic and some helpful methods.
Example of a plugin query stage implementation:
QueryStage
instance and initializes it.process
method (see the example above) for each query passing through the query pipeline.process
method can be called from multiple concurrently-running threads. Additionally, Fusion can initialize and maintain multiple stage instances with the same configuration in separate query service nodes. Therefore, it is important to make sure the plugin stage implementation is thread-safe and processing logic is stateless.
The plugin stage may throw an exception while processing a query. This does not cause any side effects; the query will simply not be processed anymore. The whole query pipeline will still be in use and Fusion will continue to call the process
method for other queries. Any information about thrown exceptions can be found in the logs.
init(T config, Fusion fusion)
method. This allows the stage to create any needed internal structure and validate the stage configuration.
Note that initialization occurs immediately after the stage configuration has been saved in Fusion. After this the stage instance can be maintained and re-used by Fusion for extensive periods of time even if no queries pass through the stage. You should be mindful of this fact when making decisions on resource allocations.
process(DslQueryRequestResponse query, Context context)
on every incoming query.
Note that multiple threads can call the process
method concurrently, therefore its implementation must be thread-safe.
QueryStageConfig
defines configuration options specific to a particular query stage instance. These options will be available to the end user via the Fusion UI and API. The plugin config class must extend com.lucidworks.querying.config.QueryStageConfig
and be annotated with @RootSchema
.
By adding @Property
and type annotations to your stage configuration interface methods, you can define metadata and type constraints for your plugin configuration fields. This is very similar to Fusion’s connector configuration schema. For more detailed information on the configuration and schema capabilities, see Java Connector Development.
Here is an example of a simple stage configuration schema definition:
Fusion
object. This object is passed to the stage during the initialization phase.
RestCall
API provides access to the Fusion REST API.
DslQueryRequestResponse
is a representation of a query request and response. In Fusion, both the query request and response are treated and tracked as one entity. This is the class that is passed through to the process
method and may be manipulated to inspect/update the request and/or response.
DslQueryRequest
is a representation of a query request. You can access this via the QueryRequestAndResponse
class. It contains information about the query parameters, the headers, as well as the HTTP method called.
DslQueryResponse
is a representation of a query response. You can access this via the QueryRequestAndResponse
class. It contains information about the documents, the facets, and any highlighted terms.