Search in sources :

Example 1 with ExplainPhase

use of org.opensearch.search.fetch.subphase.ExplainPhase in project OpenSearch by opensearch-project.

the class SearchModule method registerFetchSubPhases.

private void registerFetchSubPhases(List<SearchPlugin> plugins) {
    registerFetchSubPhase(new ExplainPhase());
    registerFetchSubPhase(new FetchDocValuesPhase());
    registerFetchSubPhase(new ScriptFieldsPhase());
    registerFetchSubPhase(new FetchSourcePhase());
    registerFetchSubPhase(new FetchFieldsPhase());
    registerFetchSubPhase(new FetchVersionPhase());
    registerFetchSubPhase(new SeqNoPrimaryTermPhase());
    registerFetchSubPhase(new MatchedQueriesPhase());
    registerFetchSubPhase(new HighlightPhase(highlighters));
    registerFetchSubPhase(new FetchScorePhase());
    FetchPhaseConstructionContext context = new FetchPhaseConstructionContext(highlighters);
    registerFromPlugin(plugins, p -> p.getFetchSubPhases(context), this::registerFetchSubPhase);
}
Also used : ScriptFieldsPhase(org.opensearch.search.fetch.subphase.ScriptFieldsPhase) ExplainPhase(org.opensearch.search.fetch.subphase.ExplainPhase) MatchedQueriesPhase(org.opensearch.search.fetch.subphase.MatchedQueriesPhase) FetchSourcePhase(org.opensearch.search.fetch.subphase.FetchSourcePhase) FetchScorePhase(org.opensearch.search.fetch.subphase.FetchScorePhase) SeqNoPrimaryTermPhase(org.opensearch.search.fetch.subphase.SeqNoPrimaryTermPhase) FetchPhaseConstructionContext(org.opensearch.plugins.SearchPlugin.FetchPhaseConstructionContext) FetchDocValuesPhase(org.opensearch.search.fetch.subphase.FetchDocValuesPhase) FetchVersionPhase(org.opensearch.search.fetch.subphase.FetchVersionPhase) FetchFieldsPhase(org.opensearch.search.fetch.subphase.FetchFieldsPhase) HighlightPhase(org.opensearch.search.fetch.subphase.highlight.HighlightPhase)

Example 2 with ExplainPhase

use of org.opensearch.search.fetch.subphase.ExplainPhase in project OpenSearch by opensearch-project.

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, registryForPlugin(registersDupeHighlighter));
    SearchPlugin registersDupeSuggester = new SearchPlugin() {

        @Override
        public List<SearchPlugin.SuggesterSpec<?>> getSuggesters() {
            return singletonList(new SuggesterSpec<>(TermSuggestionBuilder.SUGGESTION_NAME, TermSuggestionBuilder::new, TermSuggestionBuilder::fromXContent, TermSuggestion::new));
        }
    };
    expectThrows(IllegalArgumentException.class, registryForPlugin(registersDupeSuggester));
    SearchPlugin registersDupeScoreFunction = new SearchPlugin() {

        @Override
        public List<ScoreFunctionSpec<?>> getScoreFunctions() {
            return singletonList(new ScoreFunctionSpec<>(GaussDecayFunctionBuilder.NAME, GaussDecayFunctionBuilder::new, GaussDecayFunctionBuilder.PARSER));
        }
    };
    expectThrows(IllegalArgumentException.class, registryForPlugin(registersDupeScoreFunction));
    SearchPlugin registersDupeSignificanceHeuristic = new SearchPlugin() {

        @Override
        public List<SignificanceHeuristicSpec<?>> getSignificanceHeuristics() {
            return singletonList(new SignificanceHeuristicSpec<>(ChiSquare.NAME, ChiSquare::new, ChiSquare.PARSER));
        }
    };
    expectThrows(IllegalArgumentException.class, registryForPlugin(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, registryForPlugin(registersDupeMovAvgModel));
    SearchPlugin registersDupeFetchSubPhase = new SearchPlugin() {

        @Override
        public List<FetchSubPhase> getFetchSubPhases(FetchPhaseConstructionContext context) {
            return singletonList(new ExplainPhase());
        }
    };
    expectThrows(IllegalArgumentException.class, registryForPlugin(registersDupeFetchSubPhase));
    SearchPlugin registersDupeQuery = new SearchPlugin() {

        @Override
        public List<SearchPlugin.QuerySpec<?>> getQueries() {
            return singletonList(new QuerySpec<>(TermQueryBuilder.NAME, TermQueryBuilder::new, TermQueryBuilder::fromXContent));
        }
    };
    expectThrows(IllegalArgumentException.class, registryForPlugin(registersDupeQuery));
    SearchPlugin registersDupeAggregation = new SearchPlugin() {

        @Override
        public List<AggregationSpec> getAggregations() {
            return singletonList(new AggregationSpec(TermsAggregationBuilder.NAME, TermsAggregationBuilder::new, TermsAggregationBuilder.PARSER));
        }
    };
    expectThrows(IllegalArgumentException.class, registryForPlugin(registersDupeAggregation));
    SearchPlugin registersDupePipelineAggregation = new SearchPlugin() {

        @Override
        public List<PipelineAggregationSpec> getPipelineAggregations() {
            return singletonList(new PipelineAggregationSpec(DerivativePipelineAggregationBuilder.NAME, DerivativePipelineAggregationBuilder::new, DerivativePipelineAggregator::new, DerivativePipelineAggregationBuilder::parse).addResultReader(InternalDerivative::new));
        }
    };
    expectThrows(IllegalArgumentException.class, registryForPlugin(registersDupePipelineAggregation));
    SearchPlugin registersDupeRescorer = new SearchPlugin() {

        @Override
        public List<RescorerSpec<?>> getRescorers() {
            return singletonList(new RescorerSpec<>(QueryRescorerBuilder.NAME, QueryRescorerBuilder::new, QueryRescorerBuilder::fromXContent));
        }
    };
    expectThrows(IllegalArgumentException.class, registryForPlugin(registersDupeRescorer));
}
Also used : MovAvgModel(org.opensearch.search.aggregations.pipeline.MovAvgModel) ExplainPhase(org.opensearch.search.fetch.subphase.ExplainPhase) SearchPlugin(org.opensearch.plugins.SearchPlugin) DerivativePipelineAggregationBuilder(org.opensearch.search.aggregations.pipeline.DerivativePipelineAggregationBuilder) PlainHighlighter(org.opensearch.search.fetch.subphase.highlight.PlainHighlighter) DerivativePipelineAggregator(org.opensearch.search.aggregations.pipeline.DerivativePipelineAggregator) FetchSubPhase(org.opensearch.search.fetch.FetchSubPhase) UnifiedHighlighter(org.opensearch.search.fetch.subphase.highlight.UnifiedHighlighter) Highlighter(org.opensearch.search.fetch.subphase.highlight.Highlighter) FastVectorHighlighter(org.opensearch.search.fetch.subphase.highlight.FastVectorHighlighter) PlainHighlighter(org.opensearch.search.fetch.subphase.highlight.PlainHighlighter) CustomHighlighter(org.opensearch.search.fetch.subphase.highlight.CustomHighlighter)

Aggregations

ExplainPhase (org.opensearch.search.fetch.subphase.ExplainPhase)2 SearchPlugin (org.opensearch.plugins.SearchPlugin)1 FetchPhaseConstructionContext (org.opensearch.plugins.SearchPlugin.FetchPhaseConstructionContext)1 DerivativePipelineAggregationBuilder (org.opensearch.search.aggregations.pipeline.DerivativePipelineAggregationBuilder)1 DerivativePipelineAggregator (org.opensearch.search.aggregations.pipeline.DerivativePipelineAggregator)1 MovAvgModel (org.opensearch.search.aggregations.pipeline.MovAvgModel)1 FetchSubPhase (org.opensearch.search.fetch.FetchSubPhase)1 FetchDocValuesPhase (org.opensearch.search.fetch.subphase.FetchDocValuesPhase)1 FetchFieldsPhase (org.opensearch.search.fetch.subphase.FetchFieldsPhase)1 FetchScorePhase (org.opensearch.search.fetch.subphase.FetchScorePhase)1 FetchSourcePhase (org.opensearch.search.fetch.subphase.FetchSourcePhase)1 FetchVersionPhase (org.opensearch.search.fetch.subphase.FetchVersionPhase)1 MatchedQueriesPhase (org.opensearch.search.fetch.subphase.MatchedQueriesPhase)1 ScriptFieldsPhase (org.opensearch.search.fetch.subphase.ScriptFieldsPhase)1 SeqNoPrimaryTermPhase (org.opensearch.search.fetch.subphase.SeqNoPrimaryTermPhase)1 CustomHighlighter (org.opensearch.search.fetch.subphase.highlight.CustomHighlighter)1 FastVectorHighlighter (org.opensearch.search.fetch.subphase.highlight.FastVectorHighlighter)1 HighlightPhase (org.opensearch.search.fetch.subphase.highlight.HighlightPhase)1 Highlighter (org.opensearch.search.fetch.subphase.highlight.Highlighter)1 PlainHighlighter (org.opensearch.search.fetch.subphase.highlight.PlainHighlighter)1