From 27f0d82102464f4e6374c14244a4e7b04af5d9de Mon Sep 17 00:00:00 2001 From: Billy Bao Date: Thu, 30 Oct 2025 17:30:54 +0800 Subject: [PATCH] Fix: opensearch retrieval error (#10891) ### What problem does this PR solve? Fix: opensearch retrieval error #10828 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/nlp/search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rag/nlp/search.py b/rag/nlp/search.py index 81df8d34a..b64c08024 100644 --- a/rag/nlp/search.py +++ b/rag/nlp/search.py @@ -400,7 +400,7 @@ class Dealer: page_index = (page % max_pages) - 1 begin = max(page_index * page_size, 0) sim = sim[begin : begin + page_size] - sim_np = np.array(sim) + sim_np = np.array(sim, dtype=np.float64) idx = np.argsort(sim_np * -1) dim = len(sres.query_vector) vector_column = f"q_{dim}_vec" @@ -408,7 +408,7 @@ class Dealer: filtered_count = (sim_np >= similarity_threshold).sum() ranks["total"] = int(filtered_count) # Convert from np.int64 to Python int otherwise JSON serializable error for i in idx: - if sim[i] < similarity_threshold: + if np.float64(sim[i]) < similarity_threshold: break id = sres.ids[i]