Skip to content

[Feature Request] Add extension points for pre/post collecting scores in QueryPhase #17593

Open
@martin-gaievski

Description

@martin-gaievski

Is your feature request related to a problem? Please describe

Currently, the core OpenSearch is missing an extension point that allows registering new implementations of CollectorManager and performing post-processing, such as reducing collected results. Such a collector manager can be used in multiple scenarios for custom query types like hybrid queries.

Describe the solution you'd like

Extensions should be executed before and after scores are collected. A good place to integrate this is within the QueryPhase.execute() method, similar to what is done for AggregationProcessor.

New interface name can be QueryPhaseExtension, with methods for pre and post hook points.

public interface QueryPhaseExtension {
    void beforeScoreCollection(SearchContext context);
    void afterScoreCollection(SearchContext context);
}

QueryPhaseExtension can be registered in QueryPhaseSearcher and returned by new queryPhaseExtensions() method. Constructor for QueryPhase already accepts an instance of this class.

Related component

Search

Describe alternatives you've considered

Today it's possible to use AggregationProcessor for the same. It's not a proper usage of this extension point, and can be changed at any time. Introducing a dedicated extension point for score collection will provide a more stable and intended solution.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SearchSearch query, autocomplete ...etcenhancementEnhancement or improvement to existing feature or request

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions