Skip to content

Commit 42d2135

Browse files
committed
fix for small data usecase
1 parent 325a21e commit 42d2135

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/IVFVectorsReader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,12 @@ public final void search(String field, float[] target, KnnCollector knnCollector
290290
parentCentroidQueue.add(-1, 0.f);
291291
}
292292

293+
int bulkParentThreshold = (int) Math.ceil(parentCentroidQueue.size() * 0.5);
294+
293295
while (parentCentroidQueue.size() > 0 && (centroidsVisited < nProbe || knnCollectorImpl.numCollected() < knnCollector.k())) {
294296
NeighborQueue centroidQueue = new NeighborQueue(centroidQueryScorer.size(), true);
295297
int parentsToExplore = 0;
296-
while (parentCentroidQueue.size() > 0 && parentsToExplore < parentCentroidQueryScorer.size() * 0.5) {
298+
while (parentCentroidQueue.size() > 0 && parentsToExplore < bulkParentThreshold) {
297299
int parentCentroidOrdinal = parentCentroidQueue.pop();
298300

299301
int childCentroidOrdinal;

0 commit comments

Comments
 (0)