Repository navigation
fix(vfs-store): segment CJK/mixed queries and relax short-term recall drop - #254
Open
humandebri wants to merge 3 commits into
Open
humandebri wants to merge 3 commits into
humandebri wants to merge 3 commits into
Conversation
…call, prefilter, and NUL safety
…x case-insensitive FTS dedupe, and add PBT
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.
Summary
Fixes the root causes in
crates/vfs_store/src/fs_search.rsthat caused unspaced CJK and mixed-language natural-language queries to return zero or irrelevant hits on the first search/context call:Unicode script-boundary segmentation (
segment_cjk_query_token):build_search_query_planonly split on whitespace, turning unspaced CJK/mixed clauses (e.g."Hono リクエストJSONをZodスキーマで検証する"or"今年副業で35万円くらい稼いだんだけど確定申告いる?") into a single unmatchable FTS5 phrase.AsciiWord,Han,Katakanaincludingーwhile trimming leadingー,Hangul,Hiragana), dropping hiragana particle/conjugation noise when>=3-char content terms exist while preserving standalone hiragana roots (e.g."ふるさと納税"), and capping FTS terms at 16."検索改善","長期記憶 検索精度","shared-bench-search") keep exact parity.Per-term CJK content-substring matching & Hangul support:
load_content_substring_candidatessearched for literalinstr(content, raw_query)on CJK queries, failing on multi-term 2-char CJK queries ("家賃 退去") or punctuation-suffixed queries ("設計?").content_termsindividually (capped at 12) with AND first, and falls back to OR across>=2-char terms whenexact_ftsisNoneand AND yields zero rows. Also includes Hangul incontains_cjkso 2-char Korean terms ("유출") work viacontent_substring, and addscontent_termsas fallback anchors for Light previews.Preserve FTS recall when strict short-term filtering empties all candidates:
filter_candidates_on_short_terms, strict all-short-term matches are still preferred (preserving"AI agents"and"AI ML"precision). Whenstrictis empty and multi-term FTS recall (recall_fts) is active (e.g."Hono 日本語 CORS origin 許可"orquery_contextwith natural-language task + entities), retain the FTS recall candidates instead of dropping everything to 0.Frozen Corpus Impact (
tests/fs_search_corpus.rs)34 -> 34(0 regressions)1/6 -> 5/6hit@20:dev-japanese-mixed(Hono 日本語 CORS origin 許可):None (0 hits) -> rank 1holdout-basic(Hono ユーザー名とパスワードでBasic認証をかけたい):None -> rank 4holdout-upload(Hono parseBody 同名ファイルを複数受け取る):rank 4 -> rank 4holdout-pretty(Hono JSONレスポンスを見やすく整形したい):None -> rank 9holdout-dom-stable(Motoko アップグレード時のstable memoryへのシリアライズを不要にする仕組み):None -> rank 1holdout-zod(unlabeled): top 5 are now allwith-zod/zod-validator-middlewaredocsVerification
cargo fmt -p vfs-store -- --check: cleancargo clippy -p vfs-store --tests -- -D warnings: cleancargo test -p vfs-store: all unit, integration, corpus, and proptests pass (including new tests infs_search.rsandfs_store_search.rs)