Skip to content

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

Fix: doc_aggs not correctly returned when no chunks retrieved. (#11578)

Billy Bao982ed233a227
diff --git a/rag/nlp/search.py b/rag/nlp/search.py
index e282cbd72a..084f7b48f2 100644
--- a/rag/nlp/search.py
+++ b/rag/nlp/search.py
@@ -424,6 +424,7 @@ class Dealer:
sim_np = np.array(sim, dtype=np.float64)
if sim_np.size == 0:
+ ranks["doc_aggs"] = []
return ranks
sorted_idx = np.argsort(sim_np * -1)
@@ -433,6 +434,7 @@ class Dealer:
ranks["total"] = int(filtered_count)
if filtered_count == 0:
+ ranks["doc_aggs"] = []
return ranks
max_pages = max(RERANK_LIMIT // max(page_size, 1), 1)