diff --git a/server/src/main/java/org/elasticsearch/index/mapper/vectors/VectorSimilarityFloatValueSource.java b/server/src/main/java/org/elasticsearch/index/mapper/vectors/VectorSimilarityFloatValueSource.java index 540533a1b2b7d..04b2a906d6dad 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/vectors/VectorSimilarityFloatValueSource.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/vectors/VectorSimilarityFloatValueSource.java @@ -50,18 +50,14 @@ public DoubleValues getValues(LeafReaderContext ctx, DoubleValues scores) throws final KnnVectorValues.DocIndexIterator iterator = vectorValues.iterator(); return new DoubleValues() { - private int docId = -1; - @Override public double doubleValue() throws IOException { vectorOpsCount++; - return vectorSimilarityFunction.compare(target, vectorValues.vectorValue(docId)); + return vectorSimilarityFunction.compare(target, vectorValues.vectorValue(iterator.index())); } @Override public boolean advanceExact(int doc) throws IOException { - assert doc > iterator.docID(); - docId = doc; return doc >= iterator.docID() && iterator.docID() != DocIdSetIterator.NO_MORE_DOCS && iterator.advance(doc) == doc; } };