Search in sources :

Example 1 with ExplainFetchSubPhase

use of org.elasticsearch.search.fetch.subphase.ExplainFetchSubPhase 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 2 with ExplainFetchSubPhase

use of org.elasticsearch.search.fetch.subphase.ExplainFetchSubPhase in project elasticsearch by elastic.

the class SearchModule method registerFetchSubPhases.

private void registerFetchSubPhases(List<SearchPlugin> plugins) {
    registerFetchSubPhase(new ExplainFetchSubPhase());
    registerFetchSubPhase(new DocValueFieldsFetchSubPhase());
    registerFetchSubPhase(new ScriptFieldsFetchSubPhase());
    registerFetchSubPhase(new FetchSourceSubPhase());
    registerFetchSubPhase(new VersionFetchSubPhase());
    registerFetchSubPhase(new MatchedQueriesFetchSubPhase());
    registerFetchSubPhase(new HighlightPhase(settings, highlighters));
    registerFetchSubPhase(new ParentFieldSubFetchPhase());
    FetchPhaseConstructionContext context = new FetchPhaseConstructionContext(highlighters);
    registerFromPlugin(plugins, p -> p.getFetchSubPhases(context), this::registerFetchSubPhase);
}
Also used : ScriptFieldsFetchSubPhase(org.elasticsearch.search.fetch.subphase.ScriptFieldsFetchSubPhase) VersionFetchSubPhase(org.elasticsearch.search.fetch.subphase.VersionFetchSubPhase) MatchedQueriesFetchSubPhase(org.elasticsearch.search.fetch.subphase.MatchedQueriesFetchSubPhase) FetchPhaseConstructionContext(org.elasticsearch.plugins.SearchPlugin.FetchPhaseConstructionContext) ExplainFetchSubPhase(org.elasticsearch.search.fetch.subphase.ExplainFetchSubPhase) ParentFieldSubFetchPhase(org.elasticsearch.search.fetch.subphase.ParentFieldSubFetchPhase) DocValueFieldsFetchSubPhase(org.elasticsearch.search.fetch.subphase.DocValueFieldsFetchSubPhase) FetchSourceSubPhase(org.elasticsearch.search.fetch.subphase.FetchSourceSubPhase) HighlightPhase(org.elasticsearch.search.fetch.subphase.highlight.HighlightPhase)

Aggregations

ExplainFetchSubPhase (org.elasticsearch.search.fetch.subphase.ExplainFetchSubPhase)2 NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)1 SearchPlugin (org.elasticsearch.plugins.SearchPlugin)1 FetchPhaseConstructionContext (org.elasticsearch.plugins.SearchPlugin.FetchPhaseConstructionContext)1 DerivativePipelineAggregationBuilder (org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregationBuilder)1 DerivativePipelineAggregator (org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator)1 MovAvgModel (org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModel)1 FetchSubPhase (org.elasticsearch.search.fetch.FetchSubPhase)1 DocValueFieldsFetchSubPhase (org.elasticsearch.search.fetch.subphase.DocValueFieldsFetchSubPhase)1 FetchSourceSubPhase (org.elasticsearch.search.fetch.subphase.FetchSourceSubPhase)1 MatchedQueriesFetchSubPhase (org.elasticsearch.search.fetch.subphase.MatchedQueriesFetchSubPhase)1 ParentFieldSubFetchPhase (org.elasticsearch.search.fetch.subphase.ParentFieldSubFetchPhase)1 ScriptFieldsFetchSubPhase (org.elasticsearch.search.fetch.subphase.ScriptFieldsFetchSubPhase)1 VersionFetchSubPhase (org.elasticsearch.search.fetch.subphase.VersionFetchSubPhase)1 CustomHighlighter (org.elasticsearch.search.fetch.subphase.highlight.CustomHighlighter)1 FastVectorHighlighter (org.elasticsearch.search.fetch.subphase.highlight.FastVectorHighlighter)1 HighlightPhase (org.elasticsearch.search.fetch.subphase.highlight.HighlightPhase)1 Highlighter (org.elasticsearch.search.fetch.subphase.highlight.Highlighter)1 PlainHighlighter (org.elasticsearch.search.fetch.subphase.highlight.PlainHighlighter)1 PostingsHighlighter (org.elasticsearch.search.fetch.subphase.highlight.PostingsHighlighter)1