Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
martin-gaievski opened this issue Mar 15, 2025 · 2 comments
Labels
enhancement Enhancement or improvement to existing feature or request Search Search query, autocomplete ...etc

Comments

@martin-gaievski
Copy link
Member

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

@sandeshkr419
Copy link
Contributor

[Search Triage] Can you please provide where exactly in the collection flow where you plan to instrument this - Collector Manager, Collectors or Leaf Collector?

@martin-gaievski
Copy link
Member Author

One of the goals I want to achieve with this request is a proper replacement for current approach that is used in hybrid query/neural search plugin. We need to inject custom CollectorManager into the search process anytime before the query phase execute() method, so it got picked up for collecting scores.
Currently the workaround team using is based on the AggregationProcessor, team created custom class that registers the collector manager in pre- phase and calls reduce for a non CSS scenario in post- phase. While it's working so far, it's not a proper usage of AggregationProcessor interface and extension points and can be changed/deleted at any moment. For instance check out this RFC #16774, where team is looking to moving aggs related logic to coordinator node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement or improvement to existing feature or request Search Search query, autocomplete ...etc
Projects
Status: 🆕 New
Development

No branches or pull requests

2 participants