From 982ed233a2278ab1daf21953f04cd07246dcf36d Mon Sep 17 00:00:00 2001 From: Billy Bao Date: Fri, 28 Nov 2025 13:09:05 +0800 Subject: [PATCH] Fix: doc_aggs not correctly returned when no chunks retrieved. (#11578) ### What problem does this PR solve? Fix: doc_aggs not correctly returned when no chunks retrieved. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/nlp/search.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rag/nlp/search.py b/rag/nlp/search.py index e282cbd72..084f7b48f 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)