-
Notifications
You must be signed in to change notification settings - Fork 187
Open
Description
I'm using Windows 10, python 3.12.10 and qdrant_client-1.15.1.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from langchain_core.documents import Document
from langchain_qdrant import FastEmbedSparse, QdrantVectorStore, RetrievalMode
from qdrant_client import QdrantClient
from qdrant_client.http.models import CollectionInfo, Distance, VectorParams, SparseVectorParams, SparseIndexParams
def test():
sparse_embeddings = FastEmbedSparse(model_name="Qdrant/bm25")
qdrant_dir = './qdrant_vector_data'
client = QdrantClient(path=qdrant_dir)
collection_name = "demo_collection"
collection_exists = client.collection_exists(collection_name)
retrieval_mode = RetrievalMode.SPARSE
if not collection_exists:
client.create_collection(
collection_name=collection_name,
sparse_vectors_config={"sparse": SparseVectorParams(index=SparseIndexParams(on_disk=True))},
)
store = QdrantVectorStore(
client=client,
collection_name=collection_name,
sparse_embedding=sparse_embeddings,
retrieval_mode=retrieval_mode,
sparse_vector_name="sparse",
)
document = Document(
page_content="This text will be deleted.",
metadata={
"source": "tweet",
"file_name": "delete.txt",
"created": "2023-01-03"
}
)
ids = store.add_documents(documents=[document]*32)
print(f'ids={ids}')
results = store.similarity_search(query="delete text", k=2)
for i, result in enumerate(results):
print(f'{i+1}\n{result.page_content}')
print(result.metadata)
input('delete ids?')
ret = store.delete(ids=ids)
print(f'delete ids result={ret}')
input('delete collection?')
ret = client.delete_collection(collection_name)
print(f'delete collection result={ret}')
db_path = os.path.join(qdrant_dir, 'collection', collection_name, 'storage.sqlite')
print(f'"{db_path}" exists={os.path.exists(db_path)}')
if __name__ == "__main__":
test()
The code ouputs "./qdrant_vector_data\collection\demo_collection\storage.sqlite" exists=True after delete_collection on Windows.
If I don't call store.delete(ids=ids), the vector data still exists in points table after delete_collection.

Metadata
Metadata
Assignees
Labels
No labels
