fix(hybrid-search): guard MatchCount=0 truncating all results#1156
Open
toy0116 wants to merge 1 commit into
Open
fix(hybrid-search): guard MatchCount=0 truncating all results#1156toy0116 wants to merge 1 commit into
toy0116 wants to merge 1 commit into
Conversation
When HybridSearch is called from the HTTP endpoint without a
match_count field, params.MatchCount defaults to Go's zero value.
The guard
if len(deduplicatedChunks) > params.MatchCount { … [:0] }
then silently truncated every result list to empty, so processSearchResults
was called with 0 chunks and returned nil — 64 RRF-fused results → 0.
Fix: treat MatchCount ≤ 0 as "no explicit limit" and fall back to the
same floor (50) used by the over-retrieval phase. Callers that set
MatchCount explicitly (chat pipeline, knowledge.go, agent tools) are
unaffected.
Verified: vector=50 + keyword=50 → RRF=64 → processSearchResults(50) → 108
final results (50 primary + 61 enrichment neighbours/parents) for
"M1000 MP frequency bands LTE cellular" query.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When HybridSearch is called from the HTTP endpoint without a match_count field, params.MatchCount defaults to Go's zero value. The guard
if len(deduplicatedChunks) > params.MatchCount { … [:0] }
then silently truncated every result list to empty, so processSearchResults was called with 0 chunks and returned nil — 64 RRF-fused results → 0.
Fix: treat MatchCount ≤ 0 as "no explicit limit" and fall back to the same floor (50) used by the over-retrieval phase. Callers that set MatchCount explicitly (chat pipeline, knowledge.go, agent tools) are unaffected.
Verified: vector=50 + keyword=50 → RRF=64 → processSearchResults(50) → 108 final results (50 primary + 61 enrichment neighbours/parents) for "M1000 MP frequency bands LTE cellular" query.
Pull Request
描述 (Description)
变更类型 (Type of Change)
影响范围 (Scope)
测试 (Testing)
测试步骤 (Test Steps)
检查清单 (Checklist)
相关 Issue
Fixes #
截图/录屏 (Screenshots/Recordings)
数据库迁移 (Database Migration)
配置变更 (Configuration Changes)
部署说明 (Deployment Notes)
其他信息 (Additional Information)