fix(store): 隔离 SQLite 与 TCVDB 的关键词查询语义#473
Conversation
YOMXXX
left a comment
There was a problem hiding this comment.
Approved.
I verified the PR locally on the branch with Node 24.15.0:
COREPACK_ENABLE_AUTO_PIN=0 pnpm vitest run src/core/store/keyword-query.test.ts— 1 file / 5 tests passedCOREPACK_ENABLE_AUTO_PIN=0 pnpm test— 5 files / 72 tests passedCOREPACK_ENABLE_AUTO_PIN=0 pnpm build— passedgit diff --check HEAD~1..HEAD— passed
This is not a duplicate of the #178 FTS5 operator-sanitization fix. It cleanly separates raw keyword text from backend-specific query syntax: SQLite builds FTS5 MATCH expressions inside the SQLite store, while TCVDB receives trimmed natural-language text for its hybrid search path. Existing low-level searchL*Fts() methods remain as compatibility entry points, and the new tests cover both L1/L0 SQLite and TCVDB boundaries.
|
Thank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program! |
Description | 描述
本 PR 修复关键词查询在 SQLite 与 TCVDB 后端之间的语义边界问题。
维护者已将 #178 定位为 #160 的标准窄范围修复,用于净化 SQLite FTS5 运算符。本 PR 不修改运算符净化逻辑,也不替代 #178,而是处理一个可以独立合并的后端抽象问题。
问题根因
当前调用方会先通过
buildFtsQuery()将用户文本转换为 SQLite FTS5MATCH表达式,再传给IMemoryStore.searchL1Fts()/searchL0Fts()。例如:
alpha beta"alpha" OR "beta"SQLite 确实需要这种表达式,但 TCVDB 的实现会把同一个参数作为原始查询文本传给服务端 embedding、BM25 和混合检索。因此,TCVDB 实际收到的是包含引号和
OR的 SQLite 语法,而不是原始自然语言,可能影响向量表示和关键词召回。修改内容
searchL1Keyword()与searchL0Keyword()接口。buildFtsQuery()。MATCH表达式。searchL1Fts()/searchL0Fts()作为兼容入口。Related Issue | 关联 Issue
Related to #160
说明:#178 仍是 #160 的标准 FTS5 运算符净化修复;本 PR 解决独立的跨后端查询语义问题,因此不使用
Fixes #160。Change Type | 修改类型
Verification | 验证
npm.cmd test -- src/core/store/keyword-query.test.ts:5/5 通过npm.cmd test:72/72 通过npm.cmd run build:通过git diff --check origin/main...HEAD:通过新增测试明确验证:
alpha beta转换为"alpha" OR "beta"。alpha beta。Self-test Checklist | 自测清单
验证截图