fix(search): 限制 FTS5 查询 token 数并统一去重#483
Open
Qiyuanqiii wants to merge 1 commit into
Open
Conversation
Collaborator
|
hank you for submitting this PR and participating in Tencent Rhino-bird Open-source Training Program! |
This was referenced Jul 13, 2026
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.
背景
#178 已被维护者确认为 #160 的标准运算符净化修复,但当前
buildFtsQuery()仍允许超长或重复输入生成大量OR子句:SQLite 官方也建议对外部可控输入限制资源复杂度:
https://www.sqlite.org/limits.html
修改内容
OR查询语义不变。与现有 PR 的边界
AND / OR / NOT / NEAR净化。本地复现结果
指示性测试:
性能复现命令:
可选:FTS 查询预算性能复现命令
下面的
oldQuery()保留 PR 修改前 fallback 路径的查询构造行为,用于与当前分支的
buildFtsQuery()做同机对比。耗时会随机器环境波动。本机参考结果:
测试截图:

验证结果
git diff --check:通过Related Issue
Related to #160
说明:#178 仍是 #160 的标准窄范围修复,本 PR 是独立的查询资源与稳定性补充。
截图