Skip to content

Commit

Permalink
fix: Raise if named vector not found in local mode while upsert (#813)
Browse files Browse the repository at this point in the history
* fix: Raise if named vector not found in local mode

* fix: Raise if named vector not found in local mode while upsert

* chore: Added test case
  • Loading branch information
hh-space-invader authored and joein committed Oct 29, 2024
1 parent 94d3e16 commit 8620bb2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions qdrant_client/local/local_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,8 @@ def _upsert_point(self, point: models.PointStruct) -> None:
"Wrong input: Unnamed vectors are not allowed when a collection has named vectors or multivectors: "
f"{vector_names}, {multivector_names}"
)
if not self.vectors and not self.multivectors:
raise ValueError(f"Wrong input: Not existing vector name error")

if point.id in self.ids:
self._update_point(point)
Expand Down
21 changes: 21 additions & 0 deletions tests/congruence_tests/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,24 @@ def test_upload_wrong_vectors():
wrong_vectors_collection,
points=[models.PointStruct(id=1, vector=unnamed_vector)],
)


def test_upsert_without_vector_name():
local_client = init_local()
remote_client = init_remote()

local_client.create_collection(collection_name=COLLECTION_NAME, vectors_config={})
if remote_client.collection_exists(collection_name=COLLECTION_NAME):
remote_client.delete_collection(collection_name=COLLECTION_NAME)
remote_client.create_collection(collection_name=COLLECTION_NAME, vectors_config={})

with pytest.raises(ValueError, match="Not existing vector name error"):
local_client.upsert(
COLLECTION_NAME, points=[models.PointStruct(id=1, vector=[0.1, 0.2, 0.3])]
)
with pytest.raises(
qdrant_client.http.exceptions.UnexpectedResponse, match="Not existing vector name error"
):
remote_client.upsert(
COLLECTION_NAME, points=[models.PointStruct(id=1, vector=[0.1, 0.2, 0.3])]
)

0 comments on commit 8620bb2

Please sign in to comment.