-
Notifications
You must be signed in to change notification settings - Fork 2.3k
#17593 Add Extension Points For Pre and Post Collection of Scores in QueryPhase #18814
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
base: main
Are you sure you want to change the base?
Conversation
❌ Gradle check result for da66380: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
try { | ||
searcher.searchWith(searchContext, indexSearcher, query, collectors, false, false); | ||
} catch (Exception ignored) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should fail the test in case of exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
* | ||
* @opensearch.api | ||
*/ | ||
@PublicApi(since = "3.0.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be 3.2.0 or whatever next version you're aiming for. 3.0.0 has been released some time ago
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
try { | ||
extension.beforeScoreCollection(searchContext); | ||
} catch (Exception e) { | ||
LOGGER.warn(new ParameterizedMessage("Failed to execute beforeScoreCollection extension [{}]", extension.getClass().getName()), e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this behavior configurable, and fail execution by default, similar to behavior of ignore_failure flag? This can be part of extension interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
/** | ||
* Unit tests for QueryPhaseExtension interface. | ||
*/ | ||
public class QueryPhaseExtensionTests extends OpenSearchTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're missing the test case for scenario when extension is throwing exception, if so please add test for such scenario
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
❌ Gradle check result for 0a0f121: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
67ddc71
to
ae4b60c
Compare
❌ Gradle check result for ae4b60c: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Atri Sharma <[email protected]> Signed-off-by: Atri Sharma <[email protected]>
ae4b60c
to
51d8de7
Compare
❌ Gradle check result for 51d8de7: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Atri Sharma <[email protected]>
❌ Gradle check result for ddf59ab: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for ddf59ab: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Flaky tests #15813 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #18814 +/- ##
============================================
+ Coverage 72.80% 72.88% +0.07%
- Complexity 68564 68570 +6
============================================
Files 5567 5567
Lines 314844 314949 +105
Branches 45675 45690 +15
============================================
+ Hits 229227 229545 +318
+ Misses 67028 66770 -258
- Partials 18589 18634 +45 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@owaiskazi19 @martin-gaievski Updated the PR and CI passes. Plsse review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thank you. Please look into failing check for low test coverage, maybe you can came up with more test scenario, the gap between actual and expected procentage is tiny
Signed-off-by: Atri Sharma <[email protected]>
beforeContext.set(searchContext); | ||
// At this point, query should be available but not results | ||
assertNotNull("SearchContext should not be null in beforeScoreCollection", searchContext); | ||
assertNotNull("Query should be available in beforeScoreCollection", searchContext.query()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also check
assertNull("Query result should be null", searchContext.queryResult());
@msfroh can you take another look? Overall LGTM |
❌ Gradle check result for 89f4afe: null Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Resolves #17593
Problem
Plugins implementing hybrid queries and neural search currently rely on AggregationProcessor workarounds to inject custom CollectorManager implementations. This approach is fragile and breaks when the aggregation system changes.
Solution
Add extension points directly in QueryPhase around the actual score collection operation:
QueryPhaseExtension
interface withbeforeScoreCollection()
andafterScoreCollection()
methodsQueryPhaseSearcher.queryPhaseExtensions()
DefaultQueryPhaseSearcher
with proper error isolationImplementation
New interface:
Testing
Unit tests verify:
No existing functionality affected.