mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
Fix random score generation when no seed is provided. (#25908)
It fixes random score generation to ensure that you will not always get the same scores on a read-only index by integrating the seed into the score computation when using doc ids. It also removes `ctx.docBase` from the formula since it might change over time if deletes are compacted while scores are supposed to be cacheable per segment.
This commit is contained in:
parent
edad7b4737
commit
876c7e0400
@ -70,7 +70,7 @@ public class RandomScoreFunction extends ScoreFunction {
|
||||
public double score(int docId, float subQueryScore) throws IOException {
|
||||
int hash;
|
||||
if (values == null) {
|
||||
hash = BitMixer.mix(ctx.docBase + docId);
|
||||
hash = BitMixer.mix(docId, saltedSeed);
|
||||
} else if (values.advanceExact(docId)) {
|
||||
hash = StringHelper.murmurhash3_x86_32(values.nextValue(), saltedSeed);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user