Fix distance matrix min samples found (#5036)

This commit is contained in:
Arnaud Gourlay
2024-09-06 14:53:20 +02:00
committed by GitHub
parent b2d22c9792
commit faa7e9f8f4

View File

@@ -204,6 +204,11 @@ impl Collection {
sampled_points.extend(filtered);
}
// if we have less than 2 points, we can't build a matrix
if sampled_points.len() < 2 {
return Ok(CollectionSearchMatrixResponse::default());
}
sampled_points.truncate(sample_size);
// sort by id for a deterministic order
sampled_points.sort_unstable_by(|(id1, _), (id2, _)| id1.cmp(id2));