Index Stage SDK
Lucidworks provides an Index Stage SDK in a public repository on GitHub with all the resources you need to develop custom index stages with Java.
Clone the repository to get started:
git clone https://github.com/lucidworks/index-stage-sdk
See Gradle quickstart documentation for more information on Java Projects.
Configuration
Project layout
The minimal project layout:
my-index-stage ├── build.gradle ├── gradle.properties ├── settings.gradle └── src └── main └── java └── MyIndexStageConfig.java └── MyIndexStage.java
Gradle build file
At a minimum the build.gradle
file must include com.lucidworks-plugins.index-stage-sdk:index-stage-plugin-sdk
. See the Github repository for a complete example.
Java code location
The default location for the Java code is in src/main/java
. Although this location can be changed, the examples use the default location.
Minimum plugin requirements
At a minimum, a plugin must contain a stage class and its related configuration. See Index Stage SDK concepts for more information on plugins.
Plugin manifest
At a minimum, the plugin manifest file should contain the following:
Parameter | Description |
---|---|
|
The version number of the manifest. |
|
The ID that Fusion’s Blob Store uses to identify the plugin. |
|
The SDK version of the plugin. This must be compatible with your Fusion version. |
|
The name of the package that will be scanned for stage classes. These classes must be annotated with |
|
The version number of the plugin. |
See the example below for more information.
Examples
This documentation uses a Gradle task, assemblePlugin , to build index stage plugins. Alternatively, plugins can be built with any build tool, assuming the file and directory structure is correct.
|
Creating a custom META-INF/MANIFEST.MF
file
Manifest-Version: 1.0
Plugin-Id: sample-plugin
Plugin-SDK-Version: 1.0.0
Plugin-Base-Package: com.lucidworks.sample
Plugin-Version: 0.0.1
Simple stage configuration schema definition
@RootSchema(
title = "Simple",
description = "Simple Index Stage"
)
public interface SimpleStageConfig extends IndexStageConfig {
@Property(
title = "Field",
description = "Name of field to add to document.",
required = true
)
@StringSchema(minLength = 1)
String newField();
@Property(
title = "Text",
description = "Sample text to put into the field."
)
@StringSchema
String text();
}
Custom index stage implementation
@Stage(type = "simple", configClass = SimpleStageConfig.class)
public class SimpleStage extends IndexStageBase<SimpleStageConfig> {
private static final Logger logger = LoggerFactory.getLogger(SimpleStage.class);
@Override
public Document process(Document document, Context context) {
String text = StringUtils.trim(config.text());
document.field(config.newField(), String.class).set(text).type(Types.STRING);
return document;
}
}
Logging
public class MyStage extends IndexStageBase<MyStageConfig> {
private static final Logger logger = LoggerFactory.getLogger(MyStage.class);
@Override
public Document process(Document document, Context context) {
// ......
logger.info("Processing document with id '{}'", document.getId());
// ......
}
}