Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(hybrid-search): guard MatchCount=0 truncating all results

toy01166ac396afb281
diff --git a/internal/application/service/knowledgebase_search.go b/internal/application/service/knowledgebase_search.go
index 605b442ff..8791e6548 100644
--- a/internal/application/service/knowledgebase_search.go
+++ b/internal/application/service/knowledgebase_search.go
@@ -236,10 +236,14 @@ func (s *knowledgeBaseService) HybridSearch(ctx context.Context,
return nil, err
}
- if len(deduplicatedChunks) > params.MatchCount {
- deduplicatedChunks = deduplicatedChunks[:params.MatchCount]
+ // Limit to MatchCount; 0 means "no explicit limit" — use over-retrieval floor (50).
+ effectiveMatchCount := params.MatchCount
+ if effectiveMatchCount <= 0 {
+ effectiveMatchCount = 50
+ }
+ if len(deduplicatedChunks) > effectiveMatchCount {
+ deduplicatedChunks = deduplicatedChunks[:effectiveMatchCount]
}
-
return s.processSearchResults(ctx, deduplicatedChunks, params.SkipContextEnrichment)
}