Skip to content

Commit 99f2908

Browse files
committed
Propagate scoring function through random sampler.
1 parent 0db51d5 commit 99f2908

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/random/RandomSamplerAggregator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ public void collect(int doc, long owningBucketOrd) throws IOException {
117117
if (scorer == null) {
118118
return LeafBucketCollector.NO_OP_COLLECTOR;
119119
}
120+
sub.setScorer(scorer);
121+
120122
final DocIdSetIterator docIt = scorer.iterator();
121123
final Bits liveDocs = aggCtx.getLeafReaderContext().reader().getLiveDocs();
122124
try {

server/src/main/java/org/elasticsearch/search/aggregations/bucket/sampler/random/RandomSamplerAggregatorFactory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,10 @@ private Weight getWeight() throws IOException {
8787
shardSeed == null ? context.shardRandomSeed() : shardSeed
8888
);
8989
BooleanQuery booleanQuery = new BooleanQuery.Builder().add(query, BooleanClause.Occur.FILTER)
90-
.add(context.query(), BooleanClause.Occur.FILTER)
90+
.add(context.query(), BooleanClause.Occur.MUST)
9191
.build();
92-
weight = context.searcher().createWeight(context.searcher().rewrite(booleanQuery), ScoreMode.COMPLETE_NO_SCORES, 1f);
92+
weight = context.searcher().createWeight(context.searcher().rewrite(booleanQuery), ScoreMode.COMPLETE, 1f);
9393
}
9494
return weight;
9595
}
96-
9796
}

0 commit comments

Comments
 (0)