
org.elasticsearch.plugin.GermanFuzzyAwareSearchAnalyzerProvider Maven / Gradle / Ivy
The newest version!
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package org.elasticsearch.plugin;
import org.apache.lucene.analysis.CharArraySet;
import org.apache.lucene.analysis.compound.hyphenation.HyphenationTree;
import org.apache.lucene.analysis.hunspell.Dictionary;
import org.apache.lucene.analysis.synonym.SynonymMap;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider;
import sirius.nlp.analyzer.de.GermanSearchAnalyzer;
import sirius.nlp.service.UpdateSynonymsService;
import sirius.nlp.util.RessourceLoading;
/**
* An analyzerprovider for {@link GermanSearchAnalyzer} which is able to use fuzzy matching.
*/
public class GermanFuzzyAwareSearchAnalyzerProvider extends AbstractIndexAnalyzerProvider {
private GermanSearchAnalyzer analyzer;
/**
* Constructs a new analyzer component, with the index name and its settings and the analyzer name.
*
* @param indexSettings the settings and the name of the index
* @param environment the env
* @param name The analyzer name
* @param settings the settings
* @param updateSynonymsService a service for dynamic synonyms
*/
public GermanFuzzyAwareSearchAnalyzerProvider(IndexSettings indexSettings,
Environment environment,
String name,
Settings settings,
UpdateSynonymsService updateSynonymsService) {
super(indexSettings, name, settings);
Dictionary hunspell = RessourceLoading.getGermanHunspellDict();
SynonymMap stemExceptionsMap = RessourceLoading.getGermanStemExceptions();
HyphenationTree hyphenTree = RessourceLoading.getGermanHyphen();
CharArraySet wordlistSet = RessourceLoading.getGermanWordList();
this.analyzer = new GermanSearchAnalyzer(hunspell,
updateSynonymsService,
null,
stemExceptionsMap,
hyphenTree,
wordlistSet,
true,
4,
7);
}
@Override
public GermanSearchAnalyzer get() {
return analyzer;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy