@@ -574,6 +574,57 @@ def delete_all_documents(self, recreate_index: bool = False) -> None:
574574 f"Error { e } when calling QdrantDocumentStore.delete_all_documents()" ,
575575 )
576576
577+ async def delete_all_documents_async (self , recreate_index : bool = False ) -> None :
578+ """
579+ Asynchronously deletes all documents from the document store.
580+
581+ :param recreate_index: Whether to recreate the index after deleting all documents.
582+ """
583+
584+ await self ._initialize_async_client ()
585+ assert self ._async_client is not None
586+
587+ if recreate_index :
588+ # get current collection config as json
589+ collection_info = await self ._async_client .get_collection (collection_name = self .index )
590+ info_json = collection_info .model_dump ()
591+
592+ # deal with the Optional use_sparse_embeddings
593+ sparse_vectors = info_json ["config" ]["params" ]["sparse_vectors" ]
594+ use_sparse_embeddings = sparse_vectors if sparse_vectors else False
595+
596+ # deal with the Optional sparse_idf
597+ hnsw_config = info_json ["config" ]["params" ]["vectors" ].get ("config" , {}).get ("hnsw_config" , None )
598+ sparse_idf = hnsw_config if use_sparse_embeddings and hnsw_config else False
599+
600+ # recreate collection
601+ await self ._set_up_collection_async (
602+ collection_name = self .index ,
603+ embedding_dim = info_json ["config" ]["params" ]["vectors" ]["size" ],
604+ recreate_collection = True ,
605+ similarity = info_json ["config" ]["params" ]["vectors" ]["distance" ].lower (),
606+ use_sparse_embeddings = use_sparse_embeddings ,
607+ sparse_idf = sparse_idf ,
608+ on_disk = info_json ["config" ]["hnsw_config" ]["on_disk" ],
609+ payload_fields_to_index = info_json ["payload_schema" ],
610+ )
611+
612+ else :
613+ try :
614+ await self ._async_client .delete (
615+ collection_name = self .index ,
616+ points_selector = rest .FilterSelector (
617+ filter = rest .Filter (
618+ must = [],
619+ )
620+ ),
621+ wait = self .wait_result_from_api ,
622+ )
623+ except Exception as e :
624+ logger .warning (
625+ f"Error { e } when calling QdrantDocumentStore.delete_all_documents_async()" ,
626+ )
627+
577628 @classmethod
578629 def from_dict (cls , data : Dict [str , Any ]) -> "QdrantDocumentStore" :
579630 """
0 commit comments