fix: push type filters into SQL WHERE clause + expose in MCP search

Type filtering (include_types/exclude_types) was applied post-fetch after
the database LIMIT, which could return zero results when all top-N
results were of the filtered type. This pushes type filters into the SQL
WHERE clause in keyword_search_with_scores() so they apply before the
limit. Semantic results still get post-fetch filtering as a safety net
since the vector index cannot filter by type.

Also adds hybrid_search_filtered() as the new primary method, with the
original hybrid_search() delegating to it with no filters for backward
compatibility. The MCP search tool now exposes include_types and
exclude_types parameters.

Includes 5 new test cases covering include, exclude, precedence,
empty results, and backward compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bot 2026-04-07 15:32:28 -05:00
parent 16fe2674ed
commit f3e25f7503
3 changed files with 565 additions and 314 deletions

605
Cargo.lock generated

File diff suppressed because it is too large Load diff