Skip to content

feat(python): expose FTS query tokenization - #8415

Merged
Xuanwo merged 1 commit into
mainfrom
yang/oss-2008-pylance-tokenize
Aug 8, 2026
Merged

feat(python): expose FTS query tokenization#8415
Xuanwo merged 1 commit into
mainfrom
yang/oss-2008-pylance-tokenize

Conversation

@BubbleCal

Copy link
Copy Markdown
Contributor

What is the new feature?

Add public lance.tokenize(...) and FtsToken(text, position) APIs for inspecting FTS query tokenization without creating a dataset or index.

Why do we need this feature?

Applications need to preview and debug the exact query terms and positions produced by Lance tokenizer configuration before running a search or building an index.

How does it work?

  • Reuse the Rust FTS tokenizer and query-token collection logic.
  • Share tokenizer option parsing with PyLance INVERTED index creation so the two APIs cannot drift.
  • Support text/code analyzer profiles, language, custom stop words, n-grams, maximum token length, and code tokenizer flags.
  • Add top-level exports, type stubs, API examples, focused tests, and user documentation.

Validation

  • CARGO_BUILD_JOBS=2 make build from python/: passed
  • New and adjacent Python tests: 8 passed
  • Runtime example: the Cats and Dogs -> [("cat", 0), ("dog", 2)]
  • uv run make lint from python/: passed
  • cargo fmt --all -- --check: passed
  • cargo clippy --all --tests --benches -- -D warnings: passed
  • git diff main...HEAD --check: passed

The only build warning was the existing macOS linker warning that __eh_frame is too large.

Linear: OSS-2008

@github-actions github-actions Bot added A-python Python bindings A-docs Documentation enhancement New feature or request labels Aug 7, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate recommendation: approve.

This closes a real FTS observability gap at the right boundary: the Python API reuses the production Rust tokenizer configuration and query-token collector, while shared option parsing keeps index creation aligned. The additive API, documentation, and focused coverage preserve the existing query and index contracts.

@Xuanwo
Xuanwo merged commit 662cea7 into main Aug 8, 2026
18 checks passed
@Xuanwo
Xuanwo deleted the yang/oss-2008-pylance-tokenize branch August 8, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docs Documentation A-python Python bindings enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants