diff --git a/src/main/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollector.java b/src/main/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollector.java index 79b134b38..4418841f4 100644 --- a/src/main/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollector.java +++ b/src/main/java/org/opensearch/neuralsearch/search/HybridTopScoreDocCollector.java @@ -56,9 +56,15 @@ public LeafCollector getLeafCollector(LeafReaderContext context) { @Override public void setScorer(Scorable scorer) throws IOException { if (scorer instanceof HybridQueryScorer) { + log.debug("passed scorer is of type HybridQueryScorer, saving it for collecting documents and scores"); compoundQueryScorer = (HybridQueryScorer) scorer; } else { compoundQueryScorer = getHybridQueryScorer(scorer); + if (Objects.isNull(compoundQueryScorer)) { + log.error( + String.format(Locale.ROOT, "cannot find scorer of type HybridQueryScorer in a hierarchy of scorer %s", scorer) + ); + } } } @@ -71,7 +77,14 @@ private HybridQueryScorer getHybridQueryScorer(final Scorable scorer) throws IOE } for (Scorable.ChildScorable childScorable : scorer.getChildren()) { HybridQueryScorer hybridQueryScorer = getHybridQueryScorer(childScorable.child); - if (hybridQueryScorer != null) { + if (Objects.nonNull(hybridQueryScorer)) { + log.debug( + String.format( + Locale.ROOT, + "found hybrid query scorer, it's child of scorer %s", + childScorable.child.getClass().getSimpleName() + ) + ); return hybridQueryScorer; } } diff --git a/src/main/java/org/opensearch/neuralsearch/search/query/HybridAggregationProcessor.java b/src/main/java/org/opensearch/neuralsearch/search/query/HybridAggregationProcessor.java index 8b584feea..42c27821f 100644 --- a/src/main/java/org/opensearch/neuralsearch/search/query/HybridAggregationProcessor.java +++ b/src/main/java/org/opensearch/neuralsearch/search/query/HybridAggregationProcessor.java @@ -47,8 +47,14 @@ public void preProcess(SearchContext context) { public void postProcess(SearchContext context) { if (isHybridQuery(context.query(), context)) { // for case when concurrent search is not enabled (default as of 2.12 release) reduce for collector - // managers is not called, and we have to call it manually. This is required as we format final + // managers is not called + // (https://github.com/opensearch-project/OpenSearch/blob/2.12/server/src/main/java/org/opensearch/search/query/QueryPhase.java#L333-L373) + // and we have to call it manually. This is required as we format final // result of hybrid query in {@link HybridTopScoreCollector#reduce} + // when concurrent search is enabled then reduce method is called as part of the search {@see + // ConcurrentQueryPhaseSearcher#searchWithCollectorManager} + // corresponding call in Lucene + // https://github.com/apache/lucene/blob/branch_9_10/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java#L700 if (!context.shouldUseConcurrentSearch()) { reduceCollectorResults(context); }