-
Notifications
You must be signed in to change notification settings - Fork 72
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
Support for post filter in hybrid query #633
Support for post filter in hybrid query #633
Conversation
Signed-off-by: Varun Jain <[email protected]>
Signed-off-by: Varun Jain <[email protected]>
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.
Overall code looks good, left just few comments
src/main/java/org/opensearch/neuralsearch/search/query/HybridCollectorManager.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/search/query/HybridCollectorManager.java
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/search/query/HybridCollectorManager.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/search/query/HybridCollectorManager.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/neuralsearch/query/HybridQueryAggregationsIT.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/neuralsearch/query/HybridQueryAggregationsIT.java
Outdated
Show resolved
Hide resolved
src/test/java/org/opensearch/neuralsearch/search/query/HybridCollectorManagerTests.java
Show resolved
Hide resolved
src/test/java/org/opensearch/neuralsearch/query/HybridQueryAggregationsIT.java
Show resolved
Hide resolved
Signed-off-by: Varun Jain <[email protected]>
src/main/java/org/opensearch/neuralsearch/util/HybridQueryUtil.java
Outdated
Show resolved
Hide resolved
@@ -216,9 +247,10 @@ public HybridCollectorNonConcurrentManager( | |||
HitsThresholdChecker hitsThresholdChecker, | |||
boolean isSingleShard, | |||
int trackTotalHitsUpTo, | |||
SortAndFormats sortAndFormats | |||
SortAndFormats sortAndFormats, | |||
Weight filteringWeight |
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 make this parameter as Optional optionalFilterWeight.
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.
If i do that then in newCollector method
if (optionalFilterWeight.isEmpty()) {
return hybridcollector;
}
This code breaks with below error
{
"error": {
"root_cause": [
{
"type": "null_pointer_exception",
"reason": "Cannot invoke \"java.util.Optional.isEmpty()\" because \"this.optionalFilterWeight\" is null"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "movies",
"node": "MpUK-BFmRRiigVIII84uIQ",
"reason": {
"type": "null_pointer_exception",
"reason": "Cannot invoke \"java.util.Optional.isEmpty()\" because \"this.optionalFilterWeight\" is null"
}
}
],
"caused_by": {
"type": "null_pointer_exception",
"reason": "Cannot invoke \"java.util.Optional.isEmpty()\" because \"this.optionalFilterWeight\" is null",
"caused_by": {
"type": "null_pointer_exception",
"reason": "Cannot invoke \"java.util.Optional.isEmpty()\" because \"this.optionalFilterWeight\" is null"
}
}
},
"status": 500
}
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.
@vibrantvarun did you construct optional with ofNullable method?
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.
yes. @navneet1v and me hopped on call and determined that it is kind of potiential bug and not the right practice to use Optional in class variables.
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.
wonder what is the potential bug, it's not a blocker for this PR but using optional definitely isn't a bug
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.
@navneet1v would you like to answer martin question
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.
It was not a bug. The implementation was not correct due to which above exception happened.
but overall when we used optional on class member the IDE was adding warnings. Hence I suggested we can skip that. It was more of a coding practice and not a serious issue
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.
Overall code looks good to me. Just resolve the comments and then its ready to be shipped.
@vibrantvarun lets ensure the GH actions are successful. |
Signed-off-by: Varun Jain <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #633 +/- ##
============================================
- Coverage 82.57% 82.54% -0.03%
- Complexity 656 659 +3
============================================
Files 52 52
Lines 2055 2063 +8
Branches 328 332 +4
============================================
+ Hits 1697 1703 +6
Misses 212 212
- Partials 146 148 +2 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Varun Jain <[email protected]>
src/main/java/org/opensearch/neuralsearch/search/query/HybridCollectorManager.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Varun Jain <[email protected]>
src/main/java/org/opensearch/neuralsearch/search/query/HybridCollectorManager.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Varun Jain <[email protected]>
Signed-off-by: Varun Jain <[email protected]>
* Post Filter for hybrid query Signed-off-by: Varun Jain <[email protected]> * Add changelog Signed-off-by: Varun Jain <[email protected]> * Addressing martin comments Signed-off-by: Varun Jain <[email protected]> * Addressing martin comments Signed-off-by: Varun Jain <[email protected]> * Addressing navneet comments Signed-off-by: Varun Jain <[email protected]> * Addressing navneet comments Signed-off-by: Varun Jain <[email protected]> * Addressing navneet comments Signed-off-by: Varun Jain <[email protected]> * Adding Coverage Signed-off-by: Varun Jain <[email protected]> --------- Signed-off-by: Varun Jain <[email protected]> (cherry picked from commit d2d4cc6)
* Post Filter for hybrid query Signed-off-by: Varun Jain <[email protected]> * Add changelog Signed-off-by: Varun Jain <[email protected]> * Addressing martin comments Signed-off-by: Varun Jain <[email protected]> * Addressing martin comments Signed-off-by: Varun Jain <[email protected]> * Addressing navneet comments Signed-off-by: Varun Jain <[email protected]> * Addressing navneet comments Signed-off-by: Varun Jain <[email protected]> * Addressing navneet comments Signed-off-by: Varun Jain <[email protected]> * Adding Coverage Signed-off-by: Varun Jain <[email protected]> --------- Signed-off-by: Varun Jain <[email protected]> (cherry picked from commit d2d4cc6) Co-authored-by: Varun Jain <[email protected]>
Description
This PR adds Support for Post filter in hybrid query.
The crux of the logic implemented in this PR is when the search request has post filter query in that, then instead of returning plain HybridTopDocCollector Object we would be returning FilteredCollectorObject which will have HybridTopDocCollector object wrapped underneath it.
Also This PR has unit tests and Integration tests for the post_filter scenario.
Testing example on local machine
Issues Resolved
508
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.