org.elasticsearch.index.analysis.AnalyzerProvider Java Examples

The following examples show how to use org.elasticsearch.index.analysis.AnalyzerProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BundlePlugin.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 7 votes vote down vote up
@Override
public Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> extra = new LinkedHashMap<>();
    if (settings.getAsBoolean("plugins.xbib.icu.enabled", true)) {
        extra.put("icu_collation", IcuCollationKeyAnalyzerProvider::new);
    }
    if (settings.getAsBoolean("plugins.xbib.hyphen.enabled", true)) {
        extra.put("hyphen", HyphenAnalyzerProvider::new);
    }
    if (settings.getAsBoolean("plugins.xbib.naturalsort.enabled", true)) {
        extra.put("naturalsort", NaturalSortKeyAnalyzerProvider::new);
    }
    if (settings.getAsBoolean("plugins.xbib.sortform.enabled", true)) {
        extra.put("sortform", SortformAnalyzerProvider::new);
    }
    if (settings.getAsBoolean("plugins.xbib.standardnumber.enabled", true)) {
        extra.put("standardnumber", (indexSettings, environment, name, factorySettings) ->
                new StandardnumberAnalyzerProvider(indexSettings, environment, name, factorySettings, standardNumberTypeParser));
    }
    return extra;
}
 
Example #2
Source File: AnalysisModule.java    From crate with Apache License 2.0 6 votes vote down vote up
public AnalysisModule(Environment environment, List<AnalysisPlugin> plugins) throws IOException {
    NamedRegistry<AnalysisProvider<CharFilterFactory>> charFilters = setupCharFilters(plugins);
    NamedRegistry<org.apache.lucene.analysis.hunspell.Dictionary> hunspellDictionaries = setupHunspellDictionaries(plugins);
    HunspellService hunspellService = new HunspellService(environment.settings(), environment, hunspellDictionaries.getRegistry());
    NamedRegistry<AnalysisProvider<TokenFilterFactory>> tokenFilters = setupTokenFilters(plugins, hunspellService);
    NamedRegistry<AnalysisProvider<TokenizerFactory>> tokenizers = setupTokenizers(plugins);
    NamedRegistry<AnalysisProvider<AnalyzerProvider<?>>> analyzers = setupAnalyzers(plugins);
    NamedRegistry<AnalysisProvider<AnalyzerProvider<?>>> normalizers = setupNormalizers();

    Map<String, PreConfiguredCharFilter> preConfiguredCharFilters = setupPreConfiguredCharFilters(plugins);
    Map<String, PreConfiguredTokenFilter> preConfiguredTokenFilters = setupPreConfiguredTokenFilters(plugins);
    Map<String, PreConfiguredTokenizer> preConfiguredTokenizers = setupPreConfiguredTokenizers(plugins);
    Map<String, PreBuiltAnalyzerProviderFactory> preConfiguredAnalyzers = setupPreBuiltAnalyzerProviderFactories(plugins);

    analysisRegistry = new AnalysisRegistry(environment,
            charFilters.getRegistry(), tokenFilters.getRegistry(), tokenizers.getRegistry(),
            analyzers.getRegistry(), normalizers.getRegistry(),
            preConfiguredCharFilters, preConfiguredTokenFilters, preConfiguredTokenizers, preConfiguredAnalyzers);
}
 
Example #3
Source File: AnalysiaHLSegPlugin.java    From elasticsearch-analysis-hlseg with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> extra = new HashMap<>();

    extra.put("hlseg_search", HLSegAnalyzerProvider::getHLSegSearchAnalyzerProvider);
    
    return extra;
}
 
Example #4
Source File: AnalysisJiebaPlugin.java    From elasticsearch-jieba-plugin with MIT License 5 votes vote down vote up
@Override
public Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
  Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> extra = new HashMap<>();

  extra.put("jieba_search", JiebaAnalyzerProvider::getJiebaSearchAnalyzerProvider);
  extra.put("jieba_index", JiebaAnalyzerProvider::getJiebaIndexAnalyzerProvider);

  return extra;
}
 
Example #5
Source File: AnalysisIkPlugin.java    From Elasticsearch-Tutorial-zh-CN with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> extra = new HashMap<>();

    extra.put("ik_smart", IkAnalyzerProvider::getIkSmartAnalyzerProvider);
    extra.put("ik_max_word", IkAnalyzerProvider::getIkAnalyzerProvider);

    return extra;
}
 
Example #6
Source File: AnalysisHanLPPlugin.java    From elasticsearch-analysis-hanlp with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> extra = new HashMap<>();

    extra.put("hanlp", HanLPAnalyzerProvider::getHanLPAnalyzerProvider);
    extra.put("hanlp_standard", HanLPAnalyzerProvider::getHanLPStandardAnalyzerProvider);
    extra.put("hanlp_index", HanLPAnalyzerProvider::getHanLPIndexAnalyzerProvider);
    extra.put("hanlp_nlp", HanLPAnalyzerProvider::getHanLPNLPAnalyzerProvider);
    extra.put("hanlp_n_short", HanLPAnalyzerProvider::getHanLPNShortAnalyzerProvider);
    extra.put("hanlp_dijkstra", HanLPAnalyzerProvider::getHanLPDijkstraAnalyzerProvider);
    extra.put("hanlp_crf", HanLPAnalyzerProvider::getHanLPCRFAnalyzerProvider);
    extra.put("hanlp_speed", HanLPAnalyzerProvider::getHanLPSpeedAnalyzerProvider);

    return extra;
}
 
Example #7
Source File: AnalysisHanLPPlugin.java    From elasticsearch-analysis-hanlp with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> analyzers = new HashMap<>();
    analyzers.put("hanlp", HanLPAnalyzerProvider::new);
    analyzers.put("hanlp-index", HanLPIndexAnalyzerProvider::new);
    return analyzers;
}
 
Example #8
Source File: MynlpPlugin.java    From mynlp with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {

    //开启异步线程,先执行一个core的分词,试图去下载依赖的资源

    Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> map = new HashMap<>();

    map.put("mynlp", MynlpAnalyzerProvider::new);
    map.put("mynlp-core", MynlpAnalyzerProvider::new);
    if (enableCws) {
        map.put("mynlp-cws", MynlpAnalyzerProvider::new);
    }

    return map;
}
 
Example #9
Source File: AnalysisLcPinyinPlugin.java    From elasticsearch-analysis-lc-pinyin with Artistic License 2.0 5 votes vote down vote up
@Override
public Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    Map<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> providerMap
            = new HashMap<String, AnalysisModule.AnalysisProvider<AnalyzerProvider<? extends Analyzer>>>();

    providerMap.put("lc_index", LcPinyinAnalyzerProvider::getIndexAnalyzerProvider);
    providerMap.put("lc_search", LcPinyinAnalyzerProvider::getSmartPinyinAnalyzerProvider);

    return providerMap;
}
 
Example #10
Source File: AnalysisModule.java    From crate with Apache License 2.0 5 votes vote down vote up
private NamedRegistry<AnalysisProvider<AnalyzerProvider<?>>> setupAnalyzers(List<AnalysisPlugin> plugins) {
    NamedRegistry<AnalysisProvider<AnalyzerProvider<?>>> analyzers = new NamedRegistry<>("analyzer");
    analyzers.register("default", StandardAnalyzerProvider::new);
    analyzers.register("standard", StandardAnalyzerProvider::new);
    analyzers.register("simple", SimpleAnalyzerProvider::new);
    analyzers.register("stop", StopAnalyzerProvider::new);
    analyzers.register("whitespace", WhitespaceAnalyzerProvider::new);
    analyzers.register("keyword", KeywordAnalyzerProvider::new);
    analyzers.extractAndRegister(plugins, AnalysisPlugin::getAnalyzers);
    return analyzers;
}
 
Example #11
Source File: AnalysisMorfologikPlugin.java    From elasticsearch-analysis-morfologik with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    return singletonMap(ANALYZER_NAME, (indexSettings, environment, name, settings) -> new MorfologikAnalyzerProvider(indexSettings, name, settings));
}
 
Example #12
Source File: ChineseWordPlugin.java    From word with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    return singletonMap("word", ChineseWordAnalyzerProvider::new);
}
 
Example #13
Source File: AnalysisModule.java    From crate with Apache License 2.0 4 votes vote down vote up
private NamedRegistry<AnalysisProvider<AnalyzerProvider<?>>> setupNormalizers() {
    return new NamedRegistry<>("normalizer");
}
 
Example #14
Source File: CommonAnalysisPlugin.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    Map<String, AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> analyzers = new TreeMap<>();
    analyzers.put("fingerprint", FingerprintAnalyzerProvider::new);
    analyzers.put("standard_html_strip", StandardHtmlStripAnalyzerProvider::new);
    analyzers.put("pattern", PatternAnalyzerProvider::new);
    analyzers.put("snowball", SnowballAnalyzerProvider::new);

    // Language analyzers:
    analyzers.put("arabic", ArabicAnalyzerProvider::new);
    analyzers.put("armenian", ArmenianAnalyzerProvider::new);
    analyzers.put("basque", BasqueAnalyzerProvider::new);
    analyzers.put("bengali", BengaliAnalyzerProvider::new);
    analyzers.put("brazilian", BrazilianAnalyzerProvider::new);
    analyzers.put("bulgarian", BulgarianAnalyzerProvider::new);
    analyzers.put("catalan", CatalanAnalyzerProvider::new);
    analyzers.put("chinese", ChineseAnalyzerProvider::new);
    analyzers.put("cjk", CjkAnalyzerProvider::new);
    analyzers.put("czech", CzechAnalyzerProvider::new);
    analyzers.put("danish", DanishAnalyzerProvider::new);
    analyzers.put("dutch", DutchAnalyzerProvider::new);
    analyzers.put("english", EnglishAnalyzerProvider::new);
    analyzers.put("finnish", FinnishAnalyzerProvider::new);
    analyzers.put("french", FrenchAnalyzerProvider::new);
    analyzers.put("galician", GalicianAnalyzerProvider::new);
    analyzers.put("german", GermanAnalyzerProvider::new);
    analyzers.put("greek", GreekAnalyzerProvider::new);
    analyzers.put("hindi", HindiAnalyzerProvider::new);
    analyzers.put("hungarian", HungarianAnalyzerProvider::new);
    analyzers.put("indonesian", IndonesianAnalyzerProvider::new);
    analyzers.put("irish", IrishAnalyzerProvider::new);
    analyzers.put("italian", ItalianAnalyzerProvider::new);
    analyzers.put("latvian", LatvianAnalyzerProvider::new);
    analyzers.put("lithuanian", LithuanianAnalyzerProvider::new);
    analyzers.put("norwegian", NorwegianAnalyzerProvider::new);
    analyzers.put("persian", PersianAnalyzerProvider::new);
    analyzers.put("portuguese", PortugueseAnalyzerProvider::new);
    analyzers.put("romanian", RomanianAnalyzerProvider::new);
    analyzers.put("russian", RussianAnalyzerProvider::new);
    analyzers.put("sorani", SoraniAnalyzerProvider::new);
    analyzers.put("spanish", SpanishAnalyzerProvider::new);
    analyzers.put("swedish", SwedishAnalyzerProvider::new);
    analyzers.put("turkish", TurkishAnalyzerProvider::new);
    analyzers.put("thai", ThaiAnalyzerProvider::new);
    return analyzers;
}
 
Example #15
Source File: AnalysisPlugin.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Override to add additional {@link Analyzer}s. See {@link #requiresAnalysisSettings(AnalysisProvider)}
 * how to on get the configuration from the index.
 */
default Map<String, AnalysisProvider<AnalyzerProvider<? extends Analyzer>>> getAnalyzers() {
    return emptyMap();
}