Skip to content

Commit

Permalink
知识库删除单文件时,把es中的内容一并删除 (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaojin3616 committed Nov 1, 2023
2 parents 396baae + d586891 commit 6ee56c9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/backend/bisheng/api/v1/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
from typing import List, Optional
from uuid import uuid4
from bisheng_langchain.vectorstores.elastic_keywords_search import ElasticKeywordsSearch

import requests
from bisheng.api.utils import access_check
Expand Down Expand Up @@ -279,6 +280,11 @@ def delete_knowledge_file(*,
res = vectore_client.col.delete(f"pk in {[p['pk'] for p in pk]}")
logger.info(f'act=delete_vector file_id={file_id} res={res}')

esvectore_client = decide_vectorstores(collection_name, 'ElasticKeywordsSearch', embeddings)
if isinstance(esvectore_client, ElasticKeywordsSearch):
esvectore_client.client.delete_by_query(index=collection_name,query={"match":{"metadata.file_id":file_id}})
logger.info(f'act=delete_es file_id={file_id} res={res}')

# minio
minio_client.MinioClient().delete_minio(str(knowledge_file.id))
# elastic
Expand Down

0 comments on commit 6ee56c9

Please sign in to comment.