diff --git a/src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java b/src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java index b63693f6a..6accbe5f5 100644 --- a/src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java +++ b/src/main/java/org/opensearch/neuralsearch/query/HybridQueryScorer.java @@ -189,7 +189,12 @@ public int docID() { */ public float[] hybridScores() throws IOException { float[] scores = new float[numSubqueries]; + //retrieves sub-matches using DisjunctionDisiScorer's two-phase iteration process. + //while the two-phase iterator can efficiently skip blocks of document IDs during matching, + //the DisiWrapper (obtained from subScorersPQ.topList()) ensures sequential document ID iteration. + //this is necessary for maintaining correct scoring order. 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 diff --git a/src/main/java/org/opensearch/neuralsearch/search/collector/HybridTopScoreDocCollector.java b/src/main/java/org/opensearch/neuralsearch/search/collector/HybridTopScoreDocCollector.java index 4ab10bceb..7a3585cf9 100644 --- a/src/main/java/org/opensearch/neuralsearch/search/collector/HybridTopScoreDocCollector.java +++ b/src/main/java/org/opensearch/neuralsearch/search/collector/HybridTopScoreDocCollector.java @@ -116,7 +116,11 @@ public void collect(int doc) throws IOException { continue; } if (hitsThresholdChecker.isThresholdReached() && totalHitsRelation == TotalHits.Relation.EQUAL_TO) { - log.info("reached hits threshold check"); + log.info( + "hit count threshold reached: total hits={}, threshold={}, action=updating_results", + totalHits, + hitsThresholdChecker.getTotalHitsThreshold() + ); totalHitsRelation = TotalHits.Relation.GREATER_THAN_OR_EQUAL_TO; } collectedHitsPerSubQuery[i]++;