Skip to content

Commit

Permalink
Switch to approximation/two phase approach everywhere in hybrid query
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <[email protected]>
  • Loading branch information
martin-gaievski committed Nov 21, 2024
1 parent 9d71188 commit 2edefec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Features
### Enhancements
### Bug Fixes
- Address inconsistent scoring in hybrid query results ([#998](https://github.com/opensearch-project/neural-search/pull/998))
### Infrastructure
### Documentation
### Maintenance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public int docID() {
*/
public float[] hybridScores() throws IOException {
float[] scores = new float[numSubqueries];
DisiWrapper topList = subScorersPQ.topList();
DisiWrapper topList = getSubMatches();
for (HybridDisiWrapper disiWrapper = (HybridDisiWrapper) topList; disiWrapper != null; disiWrapper =
(HybridDisiWrapper) disiWrapper.next) {
// check if this doc has match in the subQuery. If not, add score as 0.0 and continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,17 @@ public void collect(int doc) throws IOException {
}
// Increment total hit count which represents unique doc found on the shard
totalHits++;
hitsThresholdChecker.incrementHitCount();
for (int i = 0; i < subScoresByQuery.length; i++) {
float score = subScoresByQuery[i];
// if score is 0.0 there is no hits for that sub-query
if (score == 0) {
continue;
}
if (hitsThresholdChecker.isThresholdReached() && totalHitsRelation == TotalHits.Relation.EQUAL_TO) {
log.info("reached hits threshold check");
totalHitsRelation = TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO;
}
collectedHitsPerSubQuery[i]++;
PriorityQueue<ScoreDoc> pq = compoundScores[i];
ScoreDoc currentDoc = new ScoreDoc(doc + docBase, score);
Expand Down

0 comments on commit 2edefec

Please sign in to comment.