Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: handle missing parent chunk in retrieval_by_children (#14556)

VincentLambertb83e2ae5a282
diff --git a/rag/nlp/search.py b/rag/nlp/search.py
index 57b663400e..87c1c6682a 100644
--- a/rag/nlp/search.py
+++ b/rag/nlp/search.py
@@ -781,6 +781,13 @@ class Dealer:
vector_size = 1024
for id, cks in mom_chunks.items():
chunk = self.dataStore.get(id, idx_nms[0], [ck["kb_id"] for ck in cks])
+ if chunk is None:
+ logging.warning(
+ "Parent chunk '%s' not found in the index; falling back to %d child chunk(s).",
+ id, len(cks),
+ )
+ chunks.extend(cks)
+ continue
d = {
"chunk_id": id,
"content_ltks": " ".join([ck["content_ltks"] for ck in cks]),