Skip to content

Commit 60c84ec

Browse files
committed
iter
1 parent 9d1db8e commit 60c84ec

File tree

1 file changed

+2
-2
lines changed
  • server/src/main/java/org/elasticsearch/index/codec/vectors/cluster

1 file changed

+2
-2
lines changed

server/src/main/java/org/elasticsearch/index/codec/vectors/cluster/KMeansLocal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void cluster(FloatVectorValues vectors, KMeansIntermediate kMeansIntermediate, i
303303
private void doCluster(FloatVectorValues vectors, KMeansIntermediate kMeansIntermediate, int clustersPerNeighborhood, float soarLambda)
304304
throws IOException {
305305
float[][] centroids = kMeansIntermediate.centroids();
306-
boolean neighborAware = clustersPerNeighborhood != -1;
306+
boolean neighborAware = clustersPerNeighborhood != -1 && centroids.length > 1;
307307

308308
List<NeighborHood> neighborhoods = null;
309309
// if there are very few centroids, don't bother with neighborhoods or neighbor aware clustering
@@ -316,7 +316,7 @@ private void doCluster(FloatVectorValues vectors, KMeansIntermediate kMeansInter
316316
computeNeighborhoods(centroids, neighborhoods, clustersPerNeighborhood);
317317
}
318318
cluster(vectors, kMeansIntermediate, neighborhoods);
319-
if (neighborAware && clustersPerNeighborhood > 0) {
319+
if (neighborAware) {
320320
int[] assignments = kMeansIntermediate.assignments();
321321
assert assignments != null;
322322
assert assignments.length == vectors.size();

0 commit comments

Comments
 (0)