Skip to content

Commit

Permalink
fix: qdrant delete method
Browse files Browse the repository at this point in the history
  • Loading branch information
elisalimli committed Mar 1, 2024
1 parent c91900e commit 34a0e17
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions vectordbs/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from semantic_router.encoders import BaseEncoder
from tqdm import tqdm

from models.delete import DeleteResponse
from models.document import BaseDocumentChunk
from vectordbs.base import BaseVectorDatabase

Expand Down Expand Up @@ -89,6 +90,29 @@ async def query(self, input: str, top_k: int = MAX_QUERY_TOP_K) -> List:
]

async def delete(self, file_url: str) -> None:

# client.count(
# collection_name="{collection_name}",
# count_filter=models.Filter(
# must=[
# models.FieldCondition(key="color", match=models.MatchValue(value="red")),
# ]
# ),
# exact=True,
# )

deleted_chunks = self.client.count(
collection_name=self.index_name,
count_filter=rest.Filter(
must=[
rest.FieldCondition(
key="file_url", match=rest.MatchValue(value=file_url)
)
]
),
exact=True,
)

self.client.delete(
collection_name=self.index_name,
points_selector=rest.FilterSelector(
Expand All @@ -101,3 +125,5 @@ async def delete(self, file_url: str) -> None:
)
),
)

return DeleteResponse(num_of_deleted_chunks=deleted_chunks.count)

0 comments on commit 34a0e17

Please sign in to comment.