Skip to content

Commit

Permalink
LUCENE-10063: Fix score calculation in SimpleTextKnnVectorsFormat
Browse files Browse the repository at this point in the history
The method VectorSimilarityFunction#convertToScore already reverses the
similarity, so we shouldn't reverse it again.
  • Loading branch information
jtibshirani committed Nov 11, 2021
1 parent f725b27 commit 2a9adb8
Showing 1 changed file with 0 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ public TopDocs search(String field, float[] target, int k, Bits acceptDocs) thro
}
float[] vector = values.vectorValue();
float score = vectorSimilarity.convertToScore(vectorSimilarity.compare(vector, target));
if (vectorSimilarity.reversed) {
score = 1 / (score + 1);
}
topK.insertWithOverflow(new ScoreDoc(doc, score));
}
ScoreDoc[] topScoreDocs = new ScoreDoc[topK.size()];
Expand Down

0 comments on commit 2a9adb8

Please sign in to comment.