You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: resolve critical search bugs and improve test coverage
This commit addresses critical bugs that prevented search from working
and adds comprehensive integration tests to ensure search functionality.
Critical Bugs Fixed:
- BM25 score normalization: SQLite FTS5 bm25() scores (range [-10,0]) are
now properly normalized to [0,1] using exponential mapping. Previously,
tiny scores (~0.000001) were filtered out by default MinRelevance=0.3.
- SearchService.TotalResults: Now correctly reports total results before
pagination (was incorrectly using paginated count).
- MongoJsonQueryParser $text operator: Fixed operator precedence to check
$text before other $ operators.
- InfixQueryParser parenthesis validation: Added check for unmatched
closing parenthesis after parse completes.
- QueryLinqBuilder FTS field handling: Equal operator on FTS fields
(content/title/description) now uses Contains semantics for full-text
matching, not exact equality.
- SearchCommand FTS index sharing: Search now uses the same FTS index
instances registered with ContentStorageService, ensuring indexed data
is accessible.
Test Coverage Improvements:
- Added 33 new tests (15 integration, 18 unit)
- Coverage increased from 72.45% to 82.53%
- All 472 tests passing, 0 skipped
- Added comprehensive stemming verification tests proving run/running/runs
matching works correctly
- Added end-to-end integration tests exercising full CLI path
- Fixed null reference warnings (CS8602), disposal warnings (CA2000),
null conversion errors (CS8625)
- Added GlobalUsings.cs with global using Xunit to test projects
Why Tests Didn't Initially Catch Bugs:
- Integration tests only verified exit codes, not actual result content
- Functional tests explicitly used MinRelevance=0.0f, bypassing the filter
that failed with default MinRelevance=0.3
- No test used default search settings that end users would encounter
Files Modified:
- Core: SqliteFtsIndex.cs, SearchService.cs, QueryLinqBuilder.cs,
InfixQueryParser.cs, MongoJsonQueryParser.cs
- Main: SearchCommand.cs, ContentService.cs, SearchIndexFactory.cs
- Tests: Added 11 new test files, fixed existing test assertions
[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability","CA2000:Dispose objects before losing scope",
451
+
Justification="ContentService instances must remain alive for the duration of the search operation. CLI commands are short-lived and process exit handles cleanup.")]
0 commit comments