fix(vector_stores): handle vector=None in Milvus and Qdrant update methods (#4568)

Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Utkarsh
2026-03-27 21:50:54 +05:30
committed by GitHub
co-authored by utkarsh240799 Claude Opus 4.6
parent 68cf4e118d
commit e87240d4d9
4 changed files with 134 additions and 2 deletions
+11
View File
@@ -181,6 +181,17 @@ class MilvusDB(VectorStoreBase):
vector (List[float], optional): Updated vector.
payload (Dict, optional): Updated payload.
"""
if vector is None or payload is None:
existing = self.client.get(collection_name=self.collection_name, ids=vector_id)
if not existing:
raise ValueError(f"Vector with id {vector_id} not found in collection {self.collection_name}")
if vector is None:
vector = existing[0].get("vectors")
if vector is None:
raise ValueError(f"Existing record {vector_id} has no vector data")
if payload is None:
payload = existing[0].get("metadata")
schema = {"id": vector_id, "vectors": vector, "metadata": payload}
self.client.upsert(collection_name=self.collection_name, data=schema)
+16 -2
View File
@@ -12,6 +12,7 @@ from qdrant_client.models import (
MatchValue,
PointIdsList,
PointStruct,
PointVectors,
Range,
VectorParams,
)
@@ -326,8 +327,21 @@ class Qdrant(VectorStoreBase):
vector (list, optional): Updated vector. Defaults to None.
payload (dict, optional): Updated payload. Defaults to None.
"""
point = PointStruct(id=vector_id, vector=vector, payload=payload)
self.client.upsert(collection_name=self.collection_name, points=[point])
if vector is not None and payload is not None:
point = PointStruct(id=vector_id, vector=vector, payload=payload)
self.client.upsert(collection_name=self.collection_name, points=[point])
else:
if payload is not None:
self.client.set_payload(
collection_name=self.collection_name,
payload=payload,
points=[vector_id],
)
if vector is not None:
self.client.update_vectors(
collection_name=self.collection_name,
points=[PointVectors(id=vector_id, vector=vector)],
)
def get(self, vector_id: int) -> dict:
"""