Skip to content

fix(search): support CJK terms in FTS5 BM25 - #401

Open
KevinBarrus wants to merge 1 commit into
StarTrail-org:mainfrom
KevinBarrus:fix/fts5-cjk-tokenization
Open

fix(search): support CJK terms in FTS5 BM25#401
KevinBarrus wants to merge 1 commit into
StarTrail-org:mainfrom
KevinBarrus:fix/fts5-cjk-tokenization

Conversation

@KevinBarrus

@KevinBarrus KevinBarrus commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes FTS5 BM25 keyword retrieval for CJK text. SQLite unicode61 treats a contiguous Chinese string as one token, so a passage containing 数据库检索系统 could not be found by a query for 数据库.

New BM25 databases now index CJK runs as unigrams and bigrams. CJK queries require all bigrams in each term, while non-CJK query behavior remains unchanged. The database stores its format in SQLite PRAGMA user_version, so existing BM25 artifacts continue to use their legacy query format after an upgrade.

Adds regression coverage for Chinese substring retrieval after reopening the database and for loading an existing-format database.

Related Issues

N/A

Checklist

  • Tests pass (uv run pytest; blocked locally because the HNSW build requires system libzmq)
  • Code formatted (ruff format and ruff check)
  • Pre-commit hooks pass (pre-commit run --all-files)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant