From 5ea9fab0033a76eabe780a23ffc8c9101a4ff265 Mon Sep 17 00:00:00 2001 From: Arnaud Gourlay Date: Thu, 30 Jan 2025 11:28:52 +0100 Subject: [PATCH] Fix query per vector to not generate an empty retrieve request (#5910) --- lib/collection/src/collection/point_ops.rs | 3 +++ lib/collection/src/common/fetch_vectors.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/collection/src/collection/point_ops.rs b/lib/collection/src/collection/point_ops.rs index 4aa99848ee..8ec073b380 100644 --- a/lib/collection/src/collection/point_ops.rs +++ b/lib/collection/src/collection/point_ops.rs @@ -416,6 +416,9 @@ impl Collection { timeout: Option, hw_measurement_acc: HwMeasurementAcc, ) -> CollectionResult> { + if request.ids.is_empty() { + return Ok(Vec::new()); + } let with_payload_interface = request .with_payload .as_ref() diff --git a/lib/collection/src/common/fetch_vectors.rs b/lib/collection/src/common/fetch_vectors.rs index 900e6d5f8d..264c7dc52e 100644 --- a/lib/collection/src/common/fetch_vectors.rs +++ b/lib/collection/src/common/fetch_vectors.rs @@ -224,6 +224,10 @@ impl<'coll_name> ReferencedPoints<'coll_name> { let mut collections_names = Vec::new(); let mut vector_retrieves = Vec::new(); for (collection_name, reference_vectors_ids) in self.ids_per_collection { + // do not fetch vectors if there are no reference vectors + if reference_vectors_ids.is_empty() { + continue; + } collections_names.push(collection_name); let points: Vec<_> = reference_vectors_ids.into_iter().collect(); let vector_names: Vec<_> = self