Skip to content

Commit

Permalink
Delete non-existant points test (#895)
Browse files Browse the repository at this point in the history
* Added warnings
Added tests
Added checks

* Removed warning

* Fixed non existent idx

* Fixed text straightforwardness

* Rebuild test
  • Loading branch information
I8dNLo authored Jan 30, 2025
1 parent b4ae703 commit cfe43ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
8 changes: 5 additions & 3 deletions qdrant_client/local/local_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2247,12 +2247,14 @@ def delete_vectors(

def _delete_ids(self, ids: list[types.PointId]) -> None:
for point_id in ids:
idx = self.ids[point_id]
self.deleted[idx] = 1
if point_id in self.ids:
idx = self.ids[point_id]
self.deleted[idx] = 1

if self.storage is not None:
for point_id in ids:
self.storage.delete(point_id)
if point_id in self.ids:
self.storage.delete(point_id)

def _filter_to_ids(self, delete_filter: types.Filter) -> list[models.ExtendedPointId]:
mask = self._payload_and_non_deleted_mask(delete_filter)
Expand Down
13 changes: 12 additions & 1 deletion tests/congruence_tests/test_delete_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
def test_delete_points(local_client, remote_client):
points = generate_fixtures(100)
vector = points[0].vector["image"]

local_client.upload_points(COLLECTION_NAME, points)
remote_client.upload_points(COLLECTION_NAME, points, wait=True)

Expand Down Expand Up @@ -43,6 +42,18 @@ def test_delete_points(local_client, remote_client):
lambda c: c.search(COLLECTION_NAME, query_vector=NamedVector(name="image", vector=vector)),
)

#delete non-existent points
local_client.delete(COLLECTION_NAME, found_ids)
remote_client.delete(COLLECTION_NAME, found_ids)

compare_collections(local_client, remote_client, 100, attrs=("points_count",))

compare_client_results(
local_client,
remote_client,
lambda c: c.search(COLLECTION_NAME, query_vector=NamedVector(name="image", vector=vector)),
)


def test_delete_sparse_points():
points = generate_sparse_fixtures(100)
Expand Down

0 comments on commit cfe43ed

Please sign in to comment.