Skip to content

Commit

Permalink
Adding logs and code refs to code comments
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <[email protected]>
  • Loading branch information
martin-gaievski committed Mar 7, 2024
1 parent 67df195 commit 763061b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}
}
}

Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 763061b

Please sign in to comment.