diff --git a/app/celery.py b/app/celery.py index e387053..c8095a7 100644 --- a/app/celery.py +++ b/app/celery.py @@ -62,7 +62,15 @@ def index_file_data(content_base: Dict) -> bool: @celery.task(name="save_file") def start_save( - storage: IStorage, - docs: List[Document] + docs: List[Document], + search_results: List[Dict] ) -> bool: + from app.main import main_app + + ids = [] + if len(search_results) > 0: + ids = [item["_id"] for item in search_results] + main_app.content_base_vectorstore.delete(ids=ids) + + storage = main_app.content_base_vectorstore return storage.save(docs) diff --git a/app/indexer/content_bases.py b/app/indexer/content_bases.py index f76de0e..7998be6 100644 --- a/app/indexer/content_bases.py +++ b/app/indexer/content_bases.py @@ -21,13 +21,10 @@ def index_documents(self, docs: List[Document]): file_uuid=file_uuid, ) print("end _search_docs_by_content_base_uuid") - ids = [] - if len(results) > 0: - ids = [item["_id"] for item in results] - self.storage.delete(ids=ids) + print("start save") - task_status = start_save.delay(storage=self.storage, docs=docs) + task_status = start_save.delay(search_results=results, docs=docs) return task_status.wait() def index(self, texts: List, metadatas: dict):