Skip to content

Commit

Permalink
fixing weight null check
Browse files Browse the repository at this point in the history
Signed-off-by: Sandesh Kumar <[email protected]>
  • Loading branch information
sandeshkr419 committed Feb 3, 2024
1 parent 8922b88 commit b555118
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,16 @@ LeafBucketCollector termDocFreqCollector(
SortedSetDocValues globalOrds,
BiConsumer<Long, Integer> ordCountConsumer
) throws IOException {
if (weight == null) {
// Calculate weight if not assigned previously
this.weight = context.searcher().createWeight(context.query(), ScoreMode.COMPLETE_NO_SCORES, 1f);
if (weight == null || weight.count(ctx) != ctx.reader().maxDoc()) {
// Weight not assigned or top-level query does not match all docs in the segment.
return null;
}

if (weight.count(ctx) == 0) {
// No documents matches top level query on this segment, we can skip it
// No documents matches top level query on this segment, we can skip the segment
return LeafBucketCollector.NO_OP_COLLECTOR;
}

if (weight.count(ctx) != ctx.reader().maxDoc()) {
// Top-level query does not match all docs in this segment.
return null;
}

Terms segmentTerms = ctx.reader().terms(this.fieldName);
if (segmentTerms == null) {
// Field is not indexed.
Expand Down

0 comments on commit b555118

Please sign in to comment.