-
Notifications
You must be signed in to change notification settings - Fork 14
Index Per Field Analyzer
This article describes how an analyzer can be configured per field in the index
In order to enable this feature you have to add the following line to your indexer/searcher configuration. You have to specify a configuration file where each field that you want to customize is configured.
index.1.analyzerconfig=${com.gentics.portalnode.confpath}/rest/analyzer.properties
For each field that is not configured in the analyzer configuration file, a org.apache.lucene.analysis.standard.StandardAnalyzer will be used.
The configuration syntax is as follows: <unique_name>.analyzerclass= <unique_name>.fieldname=
for example: name.analyzerclass=com.gentics.cr.test.lucene.analysis.TestAnalyzer name.fieldname=name
You can specify more than those parameters. They will be available in the analyzer if the analyzer supports a GenericConfiguration object.
You can easily write and configure your own analyzer. Here we will show you, how to wrap the Snowball stemmer in order to use a configured language.
package com.gentics.cr.lucene.analysis;
import org.apache.lucene.analysis.snowball.SnowballAnalyzer;
import org.apache.lucene.util.Version;
import com.gentics.cr.configuration.GenericConfiguration;
public class WrappedSnowballAnalyzer extends SnowballAnalyzer {
private static final String STEMMER_NAME_KEY = "stemmername";
/**
* Creates a SnowballAnalyzer with the configured stemmer name
* @param config
*/
public WrappedSnowballAnalyzer(GenericConfiguration config) {
super(Version.LUCENE_CURRENT, config.getString(STEMMER_NAME_KEY));
}
}
The configuration for this analyzer would look like this:
content.analyzerclass=com.gentics.cr.lucene.analysis.WrappedSnowballAnalyzer
content.fieldname=content
content.stemmername=English