Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,22 @@ async def delete_documents_async(self, document_ids: List[str]) -> None:
assert self._async_index is not None, "Index is not initialized"
await self._async_index.delete(ids=document_ids, namespace=self.namespace)

def delete_all_documents(self) -> None:
"""
Deletes all documents in the document store.
"""
self._initialize_index()
assert self._index is not None, "Index is not initialized"
self._index.delete(delete_all=True, namespace=self.namespace)

async def delete_all_documents_async(self) -> None:
"""
Asynchronously deletes all documents in the document store.
"""
await self._initialize_async_index()
assert self._async_index is not None, "Index is not initialized"
await self._async_index.delete(delete_all=True, namespace=self.namespace)

def _embedding_retrieval(
self,
query_embedding: List[float],
Expand Down
13 changes: 13 additions & 0 deletions integrations/pinecone/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,19 @@ def test_write_documents_duplicate_skip(self, document_store: PineconeDocumentSt
@pytest.mark.skip(reason="Pinecone creates a namespace only when the first document is written")
def test_delete_documents_empty_document_store(self, document_store: PineconeDocumentStore): ...

def test_delete_all_documents(self, document_store: PineconeDocumentStore):
docs = [Document(content="first doc"), Document(content="second doc")]
document_store.write_documents(docs)
assert document_store.count_documents() == 2

document_store.delete_all_documents()
assert document_store.count_documents() == 0

def test_delete_all_documents_empty_collection(self, document_store: PineconeDocumentStore):
assert document_store.count_documents() == 0
document_store.delete_all_documents()
assert document_store.count_documents() == 0

def test_embedding_retrieval(self, document_store: PineconeDocumentStore):
query_embedding = [0.1] * 768
most_similar_embedding = [0.8] * 768
Expand Down
13 changes: 13 additions & 0 deletions integrations/pinecone/tests/test_document_store_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ async def test_delete_documents(self, document_store_async: PineconeDocumentStor
await document_store_async.delete_documents_async([doc.id])
assert await document_store_async.count_documents_async() == 0

async def test_delete_all_documents_async(self, document_store_async: PineconeDocumentStore):
docs = [Document(content="first doc"), Document(content="second doc")]
await document_store_async.write_documents_async(docs)
assert await document_store_async.count_documents_async() == 2

await document_store_async.delete_all_documents_async()
assert await document_store_async.count_documents_async() == 0

async def test_delete_all_documents_async_empty_collection(self, document_store_async: PineconeDocumentStore):
assert await document_store_async.count_documents_async() == 0
await document_store_async.delete_all_documents_async()
assert await document_store_async.count_documents_async() == 0

async def test_embedding_retrieval(self, document_store_async: PineconeDocumentStore):
query_embedding = [0.1] * 768
most_similar_embedding = [0.8] * 768
Expand Down