Search in sources :

Example 6 with SearchPlugin

use of org.elasticsearch.plugins.SearchPlugin in project elasticsearch by elastic.

the class SearchModule method registerScoreFunctions.

private void registerScoreFunctions(List<SearchPlugin> plugins) {
    registerScoreFunction(new ScoreFunctionSpec<>(ScriptScoreFunctionBuilder.NAME, ScriptScoreFunctionBuilder::new, ScriptScoreFunctionBuilder::fromXContent));
    registerScoreFunction(new ScoreFunctionSpec<>(GaussDecayFunctionBuilder.NAME, GaussDecayFunctionBuilder::new, GaussDecayFunctionBuilder.PARSER));
    registerScoreFunction(new ScoreFunctionSpec<>(LinearDecayFunctionBuilder.NAME, LinearDecayFunctionBuilder::new, LinearDecayFunctionBuilder.PARSER));
    registerScoreFunction(new ScoreFunctionSpec<>(ExponentialDecayFunctionBuilder.NAME, ExponentialDecayFunctionBuilder::new, ExponentialDecayFunctionBuilder.PARSER));
    registerScoreFunction(new ScoreFunctionSpec<>(RandomScoreFunctionBuilder.NAME, RandomScoreFunctionBuilder::new, RandomScoreFunctionBuilder::fromXContent));
    registerScoreFunction(new ScoreFunctionSpec<>(FieldValueFactorFunctionBuilder.NAME, FieldValueFactorFunctionBuilder::new, FieldValueFactorFunctionBuilder::fromXContent));
    //weight doesn't have its own parser, so every function supports it out of the box.
    //Can be a single function too when not associated to any other function, which is why it needs to be registered manually here.
    namedWriteables.add(new NamedWriteableRegistry.Entry(ScoreFunctionBuilder.class, WeightBuilder.NAME, WeightBuilder::new));
    registerFromPlugin(plugins, SearchPlugin::getScoreFunctions, this::registerScoreFunction);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) SearchPlugin(org.elasticsearch.plugins.SearchPlugin) ScriptScoreFunctionBuilder(org.elasticsearch.index.query.functionscore.ScriptScoreFunctionBuilder) RandomScoreFunctionBuilder(org.elasticsearch.index.query.functionscore.RandomScoreFunctionBuilder) ScoreFunctionBuilder(org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder) Entry(org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry)

Aggregations

SearchPlugin (org.elasticsearch.plugins.SearchPlugin)6 FastVectorHighlighter (org.elasticsearch.search.fetch.subphase.highlight.FastVectorHighlighter)4 Highlighter (org.elasticsearch.search.fetch.subphase.highlight.Highlighter)4 PlainHighlighter (org.elasticsearch.search.fetch.subphase.highlight.PlainHighlighter)4 PostingsHighlighter (org.elasticsearch.search.fetch.subphase.highlight.PostingsHighlighter)4 NamedRegistry (org.elasticsearch.common.NamedRegistry)2 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)2 Entry (org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry)2 NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)2 RandomScoreFunctionBuilder (org.elasticsearch.index.query.functionscore.RandomScoreFunctionBuilder)2 ScoreFunctionBuilder (org.elasticsearch.index.query.functionscore.ScoreFunctionBuilder)2 ScriptScoreFunctionBuilder (org.elasticsearch.index.query.functionscore.ScriptScoreFunctionBuilder)2 ArrayList (java.util.ArrayList)1 Collections.unmodifiableMap (java.util.Collections.unmodifiableMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 BiConsumer (java.util.function.BiConsumer)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1