|
11 | 11 |
|
12 | 12 | from pinecone import Pinecone, PineconeAsyncio, PodSpec, ServerlessSpec |
13 | 13 | from pinecone.db_data import _Index, _IndexAsyncio |
| 14 | +from pinecone.exceptions import NotFoundException |
14 | 15 |
|
15 | 16 | from .filters import _normalize_filters, _validate_filters |
16 | 17 |
|
@@ -352,6 +353,30 @@ async def delete_documents_async(self, document_ids: List[str]) -> None: |
352 | 353 | assert self._async_index is not None, "Index is not initialized" |
353 | 354 | await self._async_index.delete(ids=document_ids, namespace=self.namespace) |
354 | 355 |
|
| 356 | + def delete_all_documents(self) -> None: |
| 357 | + """ |
| 358 | + Deletes all documents in the document store. |
| 359 | + """ |
| 360 | + self._initialize_index() |
| 361 | + assert self._index is not None, "Index is not initialized" |
| 362 | + try: |
| 363 | + self._index.delete(delete_all=True, namespace=self.namespace) |
| 364 | + except NotFoundException: |
| 365 | + # Namespace doesn't exist (empty collection), which is fine - nothing to delete |
| 366 | + logger.debug("Namespace '{namespace}' not found. Nothing to delete.", namespace=self.namespace or "default") |
| 367 | + |
| 368 | + async def delete_all_documents_async(self) -> None: |
| 369 | + """ |
| 370 | + Asynchronously deletes all documents in the document store. |
| 371 | + """ |
| 372 | + await self._initialize_async_index() |
| 373 | + assert self._async_index is not None, "Index is not initialized" |
| 374 | + try: |
| 375 | + await self._async_index.delete(delete_all=True, namespace=self.namespace) |
| 376 | + except NotFoundException: |
| 377 | + # Namespace doesn't exist (empty collection), which is fine - nothing to delete |
| 378 | + logger.debug("Namespace '{namespace}' not found. Nothing to delete.", namespace=self.namespace or "default") |
| 379 | + |
355 | 380 | def _embedding_retrieval( |
356 | 381 | self, |
357 | 382 | query_embedding: List[float], |
|
0 commit comments