@@ -534,19 +534,26 @@ def delete_all_documents(self, recreate_index: bool = False) -> None:
534534 assert self ._client is not None
535535
536536 if recreate_index :
537- # get current collection config
537+ # get current collection config as json
538538 collection_info = self ._client .get_collection (collection_name = self .index )
539+ info_json = collection_info .model_dump ()
540+
541+ # deal with the Optional use_sparse_embeddings
542+ sparse_vectors = info_json ["config" ]["params" ]["sparse_vectors" ]
543+ use_sparse_embeddings = sparse_vectors if sparse_vectors else False
544+
545+ hnsw_config = info_json ["config" ]["params" ]["vectors" ].get ("config" , {}).get ("hnsw_config" , None )
546+ sparse_idf = hnsw_config if use_sparse_embeddings and hnsw_config else False
539547
540548 # recreate collection
541549 self ._set_up_collection (
542550 collection_name = self .index ,
543- embedding_dim = collection_info . config . params . vectors . size ,
551+ embedding_dim = info_json [ " config" ][ " params" ][ " vectors" ][ " size" ] ,
544552 recreate_collection = True ,
545- similarity = collection_info .config .params .vectors .distance .value ,
546- use_sparse_embeddings = collection_info .config .params .sparse_vectors == SPARSE_VECTORS_NAME ,
547- sparse_idf = (collection_info .config .params .vectors .name == SPARSE_VECTORS_NAME )
548- and collection_info .config .params .vectors .config .hnsw_config is not None ,
549- on_disk = collection_info .config .params .vectors .config .on_disk ,
553+ similarity = info_json ["config" ]["params" ]["vectors" ]["distance" ],
554+ use_sparse_embeddings = use_sparse_embeddings ,
555+ sparse_idf = sparse_idf ,
556+ on_disk = info_json ["config" ]["hnsw_config" ]["on_disk" ],
550557 # ToDo: investigate
551558 # - CollectionInfo has payload_schema as Optional[Dict[str, PayloadSchemaType]],
552559 # - self._set_up_collection expects Optional[List[dict]]
0 commit comments