For building and deploying the examples from this document, the following third-party Software is needed:
If you are using Microsoft Windows: install the Mindbreeze SDK by executing MesSDKSetup.exe .
If you are using Linux or OSX: extract the mes-devel-<version>.zip to a folder of your choice and add the SDK/bin folder from the archive to your Path variable.
The Mindbreeze Software Development Toolkit contains a tool for generating Mindbreeze Plugin Projects: mesjavaplugin.bat for Microsoft Windows installations and mesjavaplugin.sh for Unix-based systems. The tool can be used for generating the following Mindbreeze extension types:
datasource: Crawler, context and authorization plugin for a given data source.
filter: Filter plugin for a given data type.
postfilter: Post filter transformation plugin.
itemtransformer: Item transformation plugin.
Called without parameter the mesjavaplugin tool displays its usage with examples:
The parameter <name> is the name of the plugin. The project will be generated in a folder with the name of this parameter lowercased in the current path.
The parameter <base package> is the java package where the source files will be generated.
Please follow these steps to generate and deploy a post filter transformation plugin for editing or adding custom metadata:
Note: The name of the Java file is <name>PostFilter.java whereas <name> is the plugin name parameter from the previous step.
private void processRequest(FilterAndIndexRequest.Builder request) {
// Clone the request
Metadata.Builder metadataBuilder = request.getContentBuilder().getMetadataBuilder();
NamedValue.Builder namedValueBuilder = NamedValue.newBuilder();
namedValueBuilder.setName("meta");
namedValueBuilder.addValue(ValueHelper.newBuilder("value"));
metadataBuilder.addMetadatum(namedValueBuilder)
}
Please follow these steps to generate an item transformer plugin for editing or adding custom metadata:
private void processItem(Item.Builder itemBuilder) {
itemBuilder.addProperty(
NamedValue.newBuilder()
.setName("meta")
.addValue(ValueHelper.newBuilder("value"))
);
}
As you could see in both examples, it is possible to define properties for the installed plugins from the configuration interface by adding custom plugin properties.
These configuration properties are accessible in the plugin source code from the properties map:
Map<String, List<String>> properties = null;
The init method that is retrieving the configuration properties is called automatically if the plugin implements the com.mindbreeze.enterprisesearch.mesapi.Initializable interface.
The previous example of an Item Transformer plugin now setting a metadata value to a configuration parameter named “meta” looks like:
private void processItem(Item.Builder itemBuilder) {
if (properties != null && properties.containsKey("meta")) {
List<String> values = properties.get("meta");
if (values != null && !values.isEmpty()) {
String value = values.get(0);
if (value != null) {
itemBuilder.addProperty(
NamedValue.newBuilder()
.setName("meta")
.addValue(ValueHelper.newBuilder(value))
);
}
}
}
}
The Plugin Descriptor plugins.xml describes the plugins available in the archive. The main outline is as follows:
plugins
Plugin
id
kind
extension
code
for predefined properties that are passed to the Plugin
<Group>
<label>
<LangString>
<lang>en</lang>
<value>Base Configuration</value>
</LangString>
</label>
<level>DEFAULT_LEVEL</level>
<option>
<Option>
<name>meta</name>
<input>TEXT</input>
<hint>The value that is added as the meta property.</hint>
<label>
<LangString>
<lang>en</lang>
<value>meta property value</value>
</LangString>
</label>
<option />
</Option>
</option>
</Group>
</config_option>