diff --git a/lucene/core/src/java/org/apache/lucene/search/KnnFloatVectorQuery.java b/lucene/core/src/java/org/apache/lucene/search/KnnFloatVectorQuery.java
index 2bf214850830..585893fa3c2a 100644
--- a/lucene/core/src/java/org/apache/lucene/search/KnnFloatVectorQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/KnnFloatVectorQuery.java
@@ -47,7 +47,7 @@ public class KnnFloatVectorQuery extends AbstractKnnVectorQuery {
private static final TopDocs NO_RESULTS = TopDocsCollector.EMPTY_TOPDOCS;
- final float[] target;
+ private final float[] target;
/**
* Find the k
nearest documents to the target vector according to the vectors in the
diff --git a/lucene/core/src/java/org/apache/lucene/search/TwoPhaseKnnVectorQuery.java b/lucene/core/src/java/org/apache/lucene/search/TwoPhaseKnnVectorQuery.java
index 132794d63ca7..16223e99c3c6 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TwoPhaseKnnVectorQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TwoPhaseKnnVectorQuery.java
@@ -36,6 +36,7 @@ public class TwoPhaseKnnVectorQuery extends KnnFloatVectorQuery {
private final int originalK;
private final double oversample;
+ private final float[] target;
/**
* Find the k
nearest documents to the target vector according to the vectors in the
@@ -55,6 +56,7 @@ public TwoPhaseKnnVectorQuery(
if (oversample < 0) {
throw new IllegalArgumentException("oversample must be non-negative, got " + oversample);
}
+ this.target = target;
this.originalK = k;
this.oversample = oversample;
}