Repository navigation
feat(python): add CombinedFieldsQuery for BM25F full text search - #4691
Merged
Xuanwo merged 5 commits intoOct 29, 2026
Merged
Conversation
Lance supports combined_fields (BM25F) full text queries, but the Python SDK had no class for them, and the binding rejected FtsQuery::CombinedFields when converting a query back to Python. Add CombinedFieldsQuery to lancedb.query, mirroring MultiMatchQuery, and convert it in both directions in python/src/query.rs. Unlike MultiMatchQuery, which scores each column on its own and keeps the best one, it treats the columns as one field, so an AND query also matches rows whose terms are spread across columns. Boosts are validated by Lance when the query is converted, the same as for MultiMatchQuery: each must be at least 1, with one per column.
Shows an AND query whose terms are split across two columns, which MultiMatchQuery cannot match, plus column boosts and the shared tokenizer requirement.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
Exposing Lance’s existing BM25F query remains a focused solution to the Python cross-field search gap. Local checks on the updated Lance dependency covered execution, boost validation, serialization, and nested Boolean round trips; the guide example also produced the documented results. No blocker was found.
Documentation: The revised SDK support note acknowledges Rust correctly. Keep the new Python example drafted until this API is released.
Xuanwo
approved these changes
Oct 29, 2026
Xuanwo
left a comment
Member
There was a problem hiding this comment.
Verified 16 current-head checks, the Python matrix, Gatekeeper, and targeted CombinedFields coverage; no blocking findings.
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.
Closes #4652
Lance supports
combined_fields(BM25F) full text queries, but the Python SDK had no class for them, andpython/src/query.rsraised "Combined-fields FTS queries are not yet supported in Python" when converting such a query back to Python.This adds
CombinedFieldsQuery(query, columns, *, boosts=None, operator=OR)tolancedb.query, mirroringMultiMatchQuery, and converts it in both directions inpython/src/query.rs. UnlikeMultiMatchQuery, which scores each column on its own and keeps the best one, it treats the columns as one field, so an AND query also matches rows whose terms are spread across columns. Boosts are validated by Lance during conversion, the same as forMultiMatchQuery(one per column, each at least 1).Changes:
python/python/lancedb/query.py:COMBINED_FIELDSquery type and theCombinedFieldsQueryclass.python/src/query.rs:FromPyObjectandIntoPyObjectarms forFtsQuery::CombinedFields.python/python/tests/test_fts.py: AND and OR results compared withMultiMatchQuery, boosts, and the asyncto_query_object()round trip.docs/src/python/python.md: API reference entry.Testing:
pytest python/python/tests/test_fts.pyon a local build of this branch: 85 passed.ruff format --check,ruff checkandrustfmt --check(edition 2024) are clean.The Node SDK side is not included here; it is being discussed on the issue.