Search in sources :

Example 6 with NamedXContentRegistry

use of org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class SearchModuleTests method testDoubleRegister.

public void testDoubleRegister() {
    SearchPlugin registersDupeHighlighter = new SearchPlugin() {

        @Override
        public Map<String, Highlighter> getHighlighters() {
            return singletonMap("plain", new PlainHighlighter());
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new SearchModule(Settings.EMPTY, false, singletonList(registersDupeHighlighter)));
    SearchPlugin registersDupeSuggester = new SearchPlugin() {

        public List<SearchPlugin.SuggesterSpec<?>> getSuggesters() {
            return singletonList(new SuggesterSpec<>("term", TermSuggestionBuilder::new, TermSuggestionBuilder::fromXContent));
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new NamedXContentRegistry(new SearchModule(Settings.EMPTY, false, singletonList(registersDupeSuggester)).getNamedXContents()));
    SearchPlugin registersDupeScoreFunction = new SearchPlugin() {

        @Override
        public List<ScoreFunctionSpec<?>> getScoreFunctions() {
            return singletonList(new ScoreFunctionSpec<>(GaussDecayFunctionBuilder.NAME, GaussDecayFunctionBuilder::new, GaussDecayFunctionBuilder.PARSER));
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new NamedXContentRegistry(new SearchModule(Settings.EMPTY, false, singletonList(registersDupeScoreFunction)).getNamedXContents()));
    SearchPlugin registersDupeSignificanceHeuristic = new SearchPlugin() {

        @Override
        public List<SearchExtensionSpec<SignificanceHeuristic, SignificanceHeuristicParser>> getSignificanceHeuristics() {
            return singletonList(new SearchExtensionSpec<>(ChiSquare.NAME, ChiSquare::new, ChiSquare.PARSER));
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new SearchModule(Settings.EMPTY, false, singletonList(registersDupeSignificanceHeuristic)));
    SearchPlugin registersDupeMovAvgModel = new SearchPlugin() {

        @Override
        public List<SearchExtensionSpec<MovAvgModel, MovAvgModel.AbstractModelParser>> getMovingAverageModels() {
            return singletonList(new SearchExtensionSpec<>(SimpleModel.NAME, SimpleModel::new, SimpleModel.PARSER));
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new SearchModule(Settings.EMPTY, false, singletonList(registersDupeMovAvgModel)));
    SearchPlugin registersDupeFetchSubPhase = new SearchPlugin() {

        @Override
        public List<FetchSubPhase> getFetchSubPhases(FetchPhaseConstructionContext context) {
            return singletonList(new ExplainFetchSubPhase());
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new SearchModule(Settings.EMPTY, false, singletonList(registersDupeFetchSubPhase)));
    SearchPlugin registersDupeQuery = new SearchPlugin() {

        public List<SearchPlugin.QuerySpec<?>> getQueries() {
            return singletonList(new QuerySpec<>(TermQueryBuilder.NAME, TermQueryBuilder::new, TermQueryBuilder::fromXContent));
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new NamedXContentRegistry(new SearchModule(Settings.EMPTY, false, singletonList(registersDupeQuery)).getNamedXContents()));
    SearchPlugin registersDupeAggregation = new SearchPlugin() {

        public List<AggregationSpec> getAggregations() {
            return singletonList(new AggregationSpec(TermsAggregationBuilder.NAME, TermsAggregationBuilder::new, TermsAggregationBuilder::parse));
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new NamedXContentRegistry(new SearchModule(Settings.EMPTY, false, singletonList(registersDupeAggregation)).getNamedXContents()));
    SearchPlugin registersDupePipelineAggregation = new SearchPlugin() {

        public List<PipelineAggregationSpec> getPipelineAggregations() {
            return singletonList(new PipelineAggregationSpec(DerivativePipelineAggregationBuilder.NAME, DerivativePipelineAggregationBuilder::new, DerivativePipelineAggregator::new, DerivativePipelineAggregationBuilder::parse).addResultReader(InternalDerivative::new));
        }
    };
    expectThrows(IllegalArgumentException.class, () -> new NamedXContentRegistry(new SearchModule(Settings.EMPTY, false, singletonList(registersDupePipelineAggregation)).getNamedXContents()));
}
Also used : MovAvgModel(org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel) ExplainFetchSubPhase(org.elasticsearch.search.fetch.subphase.ExplainFetchSubPhase) SearchPlugin(org.elasticsearch.plugins.SearchPlugin) DerivativePipelineAggregationBuilder(org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregationBuilder) PlainHighlighter(org.elasticsearch.search.fetch.subphase.highlight.PlainHighlighter) DerivativePipelineAggregator(org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator) ExplainFetchSubPhase(org.elasticsearch.search.fetch.subphase.ExplainFetchSubPhase) FetchSubPhase(org.elasticsearch.search.fetch.FetchSubPhase) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) CustomHighlighter(org.elasticsearch.search.fetch.subphase.highlight.CustomHighlighter) PlainHighlighter(org.elasticsearch.search.fetch.subphase.highlight.PlainHighlighter) FastVectorHighlighter(org.elasticsearch.search.fetch.subphase.highlight.FastVectorHighlighter) Highlighter(org.elasticsearch.search.fetch.subphase.highlight.Highlighter) PostingsHighlighter(org.elasticsearch.search.fetch.subphase.highlight.PostingsHighlighter)

Example 7 with NamedXContentRegistry

use of org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class AbstractSearchTestCase method setUp.

public void setUp() throws Exception {
    super.setUp();
    IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
    searchExtPlugin = new TestSearchExtPlugin();
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.singletonList(searchExtPlugin));
    List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
    entries.addAll(indicesModule.getNamedWriteables());
    entries.addAll(searchModule.getNamedWriteables());
    namedWriteableRegistry = new NamedWriteableRegistry(entries);
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) IndicesModule(org.elasticsearch.indices.IndicesModule) ArrayList(java.util.ArrayList) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry)

Example 8 with NamedXContentRegistry

use of org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class HighlightBuilderTests method init.

/**
     * setup for the whole base test class
     */
@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) SearchModule(org.elasticsearch.search.SearchModule) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Example 9 with NamedXContentRegistry

use of org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class QueryRescoreBuilderTests method init.

/**
     * setup for the whole base test class
     */
@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) SearchModule(org.elasticsearch.search.SearchModule) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Example 10 with NamedXContentRegistry

use of org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class AbstractSortTestCase method init.

@BeforeClass
public static void init() throws IOException {
    Path genericConfigFolder = createTempDir();
    Settings baseSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).put(Environment.PATH_CONF_SETTING.getKey(), genericConfigFolder).build();
    Environment environment = new Environment(baseSettings);
    ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Collections.emptyList());
    ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry(Collections.singletonList(new TestEngineService()));
    ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, scriptContextRegistry);
    scriptService = new ScriptService(baseSettings, environment, new ResourceWatcherService(baseSettings, null), scriptEngineRegistry, scriptContextRegistry, scriptSettings) {

        @Override
        public CompiledScript compile(Script script, ScriptContext scriptContext) {
            return new CompiledScript(ScriptType.INLINE, "mockName", "test", script);
        }
    };
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : Path(java.nio.file.Path) ContentPath(org.elasticsearch.index.mapper.ContentPath) CompiledScript(org.elasticsearch.script.CompiledScript) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) Script(org.elasticsearch.script.Script) CompiledScript(org.elasticsearch.script.CompiledScript) ScriptContext(org.elasticsearch.script.ScriptContext) ScriptContextRegistry(org.elasticsearch.script.ScriptContextRegistry) ScriptService(org.elasticsearch.script.ScriptService) ScriptSettings(org.elasticsearch.script.ScriptSettings) ScriptEngineRegistry(org.elasticsearch.script.ScriptEngineRegistry) Environment(org.elasticsearch.env.Environment) SearchModule(org.elasticsearch.search.SearchModule) TestEngineService(org.elasticsearch.script.ScriptServiceTests.TestEngineService) ResourceWatcherService(org.elasticsearch.watcher.ResourceWatcherService) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings) ScriptSettings(org.elasticsearch.script.ScriptSettings) IndexSettings(org.elasticsearch.index.IndexSettings) BeforeClass(org.junit.BeforeClass)

Aggregations

NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)24 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)14 Settings (org.elasticsearch.common.settings.Settings)12 SearchModule (org.elasticsearch.search.SearchModule)12 BeforeClass (org.junit.BeforeClass)8 ArrayList (java.util.ArrayList)4 BigArrays (org.elasticsearch.common.util.BigArrays)4 CircuitBreakerService (org.elasticsearch.indices.breaker.CircuitBreakerService)4 NetworkPlugin (org.elasticsearch.plugins.NetworkPlugin)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Environment (org.elasticsearch.env.Environment)3 HttpServerTransport (org.elasticsearch.http.HttpServerTransport)3 ThreadPool (org.elasticsearch.threadpool.ThreadPool)3 Path (java.nio.file.Path)2 RepositoryMetaData (org.elasticsearch.cluster.metadata.RepositoryMetaData)2 IndicesModule (org.elasticsearch.indices.IndicesModule)2 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)2 Transport (org.elasticsearch.transport.Transport)2 UserDefinedFunctionsMetadata (io.crate.expression.udf.UserDefinedFunctionsMetadata)1