Merge pull request #769 from YanSte/fix-delete

Fixe the delete
This commit is contained in:
zrguo
2025-02-14 09:42:43 +08:00
committed by GitHub

View File

@@ -1264,7 +1264,7 @@ class LightRAG:
""" """
try: try:
# 1. Get the document status and related data # 1. Get the document status and related data
doc_status = await self.doc_status.get(doc_id) doc_status = await self.doc_status.get_by_id(doc_id)
if not doc_status: if not doc_status:
logger.warning(f"Document {doc_id} not found") logger.warning(f"Document {doc_id} not found")
return return
@@ -1272,9 +1272,7 @@ class LightRAG:
logger.debug(f"Starting deletion for document {doc_id}") logger.debug(f"Starting deletion for document {doc_id}")
# 2. Get all related chunks # 2. Get all related chunks
chunks = await self.text_chunks.filter( chunks = await self.text_chunks.get_by_id(doc_id)
lambda x: x.get("full_doc_id") == doc_id
)
chunk_ids = list(chunks.keys()) chunk_ids = list(chunks.keys())
logger.debug(f"Found {len(chunk_ids)} chunks to delete") logger.debug(f"Found {len(chunk_ids)} chunks to delete")
@@ -1410,9 +1408,7 @@ class LightRAG:
logger.error(f"Document {doc_id} still exists in full_docs") logger.error(f"Document {doc_id} still exists in full_docs")
# Verify if chunks have been deleted # Verify if chunks have been deleted
remaining_chunks = await self.text_chunks.filter( remaining_chunks = await self.text_chunks.get_by_id(doc_id)
lambda x: x.get("full_doc_id") == doc_id
)
if remaining_chunks: if remaining_chunks:
logger.error(f"Found {len(remaining_chunks)} remaining chunks") logger.error(f"Found {len(remaining_chunks)} remaining chunks")