Skip to content

Commit e650d53

Browse files
committed
Use the global doc id to generate a random score (#33599)
This commit changes the random_score function to use the global docID of the document rather than the segment docID to generate random scores. As a result documents that have the same segment docID within the shard will generate different scores.
1 parent 6a989dc commit e650d53

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

server/src/main/java/org/elasticsearch/common/lucene/search/function/RandomScoreFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public LeafScoreFunction getLeafScoreFunction(LeafReaderContext ctx) {
7070
public double score(int docId, float subQueryScore) throws IOException {
7171
int hash;
7272
if (values == null) {
73-
hash = BitMixer.mix(docId, saltedSeed);
73+
hash = BitMixer.mix(ctx.docBase + docId, saltedSeed);
7474
} else if (values.advanceExact(docId)) {
7575
hash = StringHelper.murmurhash3_x86_32(values.nextValue(), saltedSeed);
7676
} else {

0 commit comments

Comments
 (0)