org.elasticsearch.plugin.analysis.pinyin.AnalysisPinyinPlugin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-analysis-pinyin Show documentation
Show all versions of elasticsearch-analysis-pinyin Show documentation
Pinyin Analysis for Elasticsearch
The newest version!
package org.elasticsearch.plugin.analysis.pinyin;
import org.apache.lucene.analysis.Analyzer;
import org.elasticsearch.index.analysis.*;
import org.elasticsearch.indices.analysis.AnalysisModule;
import org.elasticsearch.plugins.AnalysisPlugin;
import org.elasticsearch.plugins.Plugin;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class AnalysisPinyinPlugin extends Plugin implements AnalysisPlugin {
@Override
public Map> getTokenizers() {
Map> extra = new HashMap<>();
extra.put("pinyin", PinyinTokenizerFactory::new);
extra.put("pinyin_first_letter", PinyinAbbreviationsTokenizerFactory::new);
return extra;
}
@Override
public Map> getTokenFilters() {
Map> extra = new HashMap<>();
extra.put("pinyin", PinyinTokenFilterFactory::new);
return extra;
}
@Override
public Map>> getAnalyzers() {
return Collections.singletonMap("pinyin", PinyinAnalyzerProvider::new);
}
}