From f53f5982fc01afa8443b66944211f4b55bc8f4d4 Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Mon, 25 Nov 2024 11:33:01 -0800 Subject: [PATCH] Expand the log message for case when we reached the threshold of hits, add some code level comments Signed-off-by: Martin Gaievski --- .../opensearch/neuralsearch/query/HybridQueryScorer.java | 5 +++++ .../search/collector/HybridTopScoreDocCollector.java | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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]++;