Merge pull request #1156 from toy0116/pr/hybrid-search-matchcount-fix

fix(hybrid-search): guard MatchCount=0 truncating all results
main
Zhang GH 2026-08-19 20:16:23 +08:00 committed by GitHub
commit 478a6521ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 3 deletions

View File

@ -248,10 +248,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)
}