Search in sources :

Example 1 with NamedRegistry

use of org.elasticsearch.common.NamedRegistry in project elasticsearch by elastic.

the class SearchModule method setupHighlighters.

private Map<String, Highlighter> setupHighlighters(Settings settings, List<SearchPlugin> plugins) {
    NamedRegistry<Highlighter> highlighters = new NamedRegistry<>("highlighter");
    highlighters.register("fvh", new FastVectorHighlighter(settings));
    highlighters.register("plain", new PlainHighlighter());
    highlighters.register("postings", new PostingsHighlighter());
    highlighters.register("unified", new UnifiedHighlighter());
    highlighters.extractAndRegister(plugins, SearchPlugin::getHighlighters);
    return unmodifiableMap(highlighters.getRegistry());
}
Also used : NamedRegistry(org.elasticsearch.common.NamedRegistry) SearchPlugin(org.elasticsearch.plugins.SearchPlugin) PostingsHighlighter(org.elasticsearch.search.fetch.subphase.highlight.PostingsHighlighter) UnifiedHighlighter(org.elasticsearch.search.fetch.subphase.highlight.UnifiedHighlighter) PlainHighlighter(org.elasticsearch.search.fetch.subphase.highlight.PlainHighlighter) FastVectorHighlighter(org.elasticsearch.search.fetch.subphase.highlight.FastVectorHighlighter) FastVectorHighlighter(org.elasticsearch.search.fetch.subphase.highlight.FastVectorHighlighter) UnifiedHighlighter(org.elasticsearch.search.fetch.subphase.highlight.UnifiedHighlighter) PlainHighlighter(org.elasticsearch.search.fetch.subphase.highlight.PlainHighlighter) Highlighter(org.elasticsearch.search.fetch.subphase.highlight.Highlighter) PostingsHighlighter(org.elasticsearch.search.fetch.subphase.highlight.PostingsHighlighter)

Example 2 with NamedRegistry

use of org.elasticsearch.common.NamedRegistry in project crate by crate.

the class AnalysisModule method setupPreConfiguredTokenFilters.

static Map<String, PreConfiguredTokenFilter> setupPreConfiguredTokenFilters(List<AnalysisPlugin> plugins) {
    NamedRegistry<PreConfiguredTokenFilter> preConfiguredTokenFilters = new NamedRegistry<>("pre-configured token_filter");
    // Add filters available in lucene-core
    preConfiguredTokenFilters.register("lowercase", PreConfiguredTokenFilter.singleton("lowercase", true, LowerCaseFilter::new));
    preConfiguredTokenFilters.register("standard", PreConfiguredTokenFilter.singletonWithVersion("standard", false, (reader, version) -> {
        DEPRECATION_LOGGER.deprecatedAndMaybeLog("standard_deprecation", "The [standard] token filter is deprecated and will be removed in a future version.");
        return reader;
    }));
    for (AnalysisPlugin plugin : plugins) {
        for (PreConfiguredTokenFilter filter : plugin.getPreConfiguredTokenFilters()) {
            preConfiguredTokenFilters.register(filter.getName(), filter);
        }
    }
    return unmodifiableMap(preConfiguredTokenFilters.getRegistry());
}
Also used : AnalysisPlugin(org.elasticsearch.plugins.AnalysisPlugin) DeprecationLogger(org.elasticsearch.common.logging.DeprecationLogger) WhitespaceAnalyzerProvider(org.elasticsearch.index.analysis.WhitespaceAnalyzerProvider) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) Environment(org.elasticsearch.env.Environment) AnalysisPlugin.requiresAnalysisSettings(org.elasticsearch.plugins.AnalysisPlugin.requiresAnalysisSettings) ShingleTokenFilterFactory(org.elasticsearch.index.analysis.ShingleTokenFilterFactory) TokenizerFactory(org.elasticsearch.index.analysis.TokenizerFactory) PreBuiltAnalyzerProviderFactory(org.elasticsearch.index.analysis.PreBuiltAnalyzerProviderFactory) AnalyzerProvider(org.elasticsearch.index.analysis.AnalyzerProvider) Settings(org.elasticsearch.common.settings.Settings) HunspellTokenFilterFactory(org.elasticsearch.index.analysis.HunspellTokenFilterFactory) Locale(java.util.Locale) Map(java.util.Map) IndexSettings(org.elasticsearch.index.IndexSettings) StandardTokenizerFactory(org.elasticsearch.index.analysis.StandardTokenizerFactory) LowerCaseFilter(org.apache.lucene.analysis.LowerCaseFilter) KeywordAnalyzerProvider(org.elasticsearch.index.analysis.KeywordAnalyzerProvider) StopTokenFilterFactory(org.elasticsearch.index.analysis.StopTokenFilterFactory) TokenStream(org.apache.lucene.analysis.TokenStream) CharFilterFactory(org.elasticsearch.index.analysis.CharFilterFactory) StandardAnalyzerProvider(org.elasticsearch.index.analysis.StandardAnalyzerProvider) AnalysisRegistry(org.elasticsearch.index.analysis.AnalysisRegistry) IOException(java.io.IOException) NamedRegistry(org.elasticsearch.common.NamedRegistry) StopAnalyzerProvider(org.elasticsearch.index.analysis.StopAnalyzerProvider) PreConfiguredCharFilter(org.elasticsearch.index.analysis.PreConfiguredCharFilter) PreConfiguredTokenizer(org.elasticsearch.index.analysis.PreConfiguredTokenizer) AbstractTokenFilterFactory(org.elasticsearch.index.analysis.AbstractTokenFilterFactory) List(java.util.List) Version(org.elasticsearch.Version) Collections.unmodifiableMap(java.util.Collections.unmodifiableMap) SimpleAnalyzerProvider(org.elasticsearch.index.analysis.SimpleAnalyzerProvider) TokenFilterFactory(org.elasticsearch.index.analysis.TokenFilterFactory) LogManager(org.apache.logging.log4j.LogManager) PreConfiguredTokenFilter(org.elasticsearch.index.analysis.PreConfiguredTokenFilter) NamedRegistry(org.elasticsearch.common.NamedRegistry) PreConfiguredTokenFilter(org.elasticsearch.index.analysis.PreConfiguredTokenFilter) AnalysisPlugin(org.elasticsearch.plugins.AnalysisPlugin)

Example 3 with NamedRegistry

use of org.elasticsearch.common.NamedRegistry in project crate by crate.

the class AnalysisModule method setupPreConfiguredTokenizers.

static Map<String, PreConfiguredTokenizer> setupPreConfiguredTokenizers(List<AnalysisPlugin> plugins) {
    NamedRegistry<PreConfiguredTokenizer> preConfiguredTokenizers = new NamedRegistry<>("pre-configured tokenizer");
    // Temporary shim to register old style pre-configured tokenizers
    for (PreBuiltTokenizers tokenizer : PreBuiltTokenizers.values()) {
        String name = tokenizer.name().toLowerCase(Locale.ROOT);
        PreConfiguredTokenizer preConfigured;
        switch(tokenizer.getCachingStrategy()) {
            case ONE:
                preConfigured = PreConfiguredTokenizer.singleton(name, () -> tokenizer.create(Version.CURRENT), null);
                break;
            default:
                throw new UnsupportedOperationException("Caching strategy unsupported by temporary shim [" + tokenizer + "]");
        }
        preConfiguredTokenizers.register(name, preConfigured);
    }
    for (AnalysisPlugin plugin : plugins) {
        for (PreConfiguredTokenizer tokenizer : plugin.getPreConfiguredTokenizers()) {
            preConfiguredTokenizers.register(tokenizer.getName(), tokenizer);
        }
    }
    return unmodifiableMap(preConfiguredTokenizers.getRegistry());
}
Also used : NamedRegistry(org.elasticsearch.common.NamedRegistry) PreConfiguredTokenizer(org.elasticsearch.index.analysis.PreConfiguredTokenizer) AnalysisPlugin(org.elasticsearch.plugins.AnalysisPlugin)

Aggregations

NamedRegistry (org.elasticsearch.common.NamedRegistry)3 PreConfiguredTokenizer (org.elasticsearch.index.analysis.PreConfiguredTokenizer)2 AnalysisPlugin (org.elasticsearch.plugins.AnalysisPlugin)2 IOException (java.io.IOException)1 Collections.unmodifiableMap (java.util.Collections.unmodifiableMap)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 LogManager (org.apache.logging.log4j.LogManager)1 LowerCaseFilter (org.apache.lucene.analysis.LowerCaseFilter)1 TokenStream (org.apache.lucene.analysis.TokenStream)1 Version (org.elasticsearch.Version)1 IndexMetadata (org.elasticsearch.cluster.metadata.IndexMetadata)1 DeprecationLogger (org.elasticsearch.common.logging.DeprecationLogger)1 Settings (org.elasticsearch.common.settings.Settings)1 Environment (org.elasticsearch.env.Environment)1 IndexSettings (org.elasticsearch.index.IndexSettings)1 AbstractTokenFilterFactory (org.elasticsearch.index.analysis.AbstractTokenFilterFactory)1 AnalysisRegistry (org.elasticsearch.index.analysis.AnalysisRegistry)1 AnalyzerProvider (org.elasticsearch.index.analysis.AnalyzerProvider)1