From 8383a048de6fdc493f97df00ef509a3b8e251b92 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Tue, 11 Sep 2018 13:59:30 +0200 Subject: [PATCH] Use the global doc id to generate a random score 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. --- .../common/lucene/search/function/RandomScoreFunction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/common/lucene/search/function/RandomScoreFunction.java b/server/src/main/java/org/elasticsearch/common/lucene/search/function/RandomScoreFunction.java index 8694b6fa019f1..b55730f514ac9 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/search/function/RandomScoreFunction.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/search/function/RandomScoreFunction.java @@ -70,7 +70,7 @@ public LeafScoreFunction getLeafScoreFunction(LeafReaderContext ctx) { public double score(int docId, float subQueryScore) throws IOException { int hash; if (values == null) { - hash = BitMixer.mix(docId, saltedSeed); + hash = BitMixer.mix(ctx.docBase + docId, saltedSeed); } else if (values.advanceExact(docId)) { hash = StringHelper.murmurhash3_x86_32(values.nextValue(), saltedSeed); } else {