Skip to content

Feature: CombinedFieldsQuery (BM25F) in the Python SDK #4652

Closed

Description

@BHAWESHBHASKAR

SDK

Python

Description

Lance added combined_fields (BM25F) full text search, and pylance exposes it as lance.query.CombinedFieldsQuery (lance-format/lance#8550). LanceDB already depends on a Lance version with FtsQuery::CombinedFields, but the Python SDK has no class for it, and python/src/query.rs returns "Combined-fields FTS queries are not yet supported in Python" when converting one back to Python. lance-format/lance#9661 also notes that the LanceDB side still needs wiring.

Unlike MultiMatchQuery, which scores each column on its own and keeps the best one, combined fields treat the columns as one field. For example, with a row whose title is "john" and whose body is "smith", an AND query for "john smith" matches it with combined fields but not with multi match.

Proposed API, mirroring MultiMatchQuery:

from lancedb.query import CombinedFieldsQuery, FullTextOperator

table.search(
    CombinedFieldsQuery(
        "john smith",
        ["title", "body"],
        boosts=[2.0, 1.0],
        operator=FullTextOperator.AND,
    )
)

Boost validation would come from Lance (each weight at least 1, one per column), the same way MultiMatchQuery boosts are checked today. I have this ready with tests for Python and can open a PR. TypeScript could follow separately.

Activity

  1. added
    enhancement
    on Oct 24, 2026
  2. Claire-ovo commented on Oct 27, 2026

    @Claire-ovo

    @BHAWESHBHASKAR Would a separate TypeScript SDK follow-up be welcome? I checked main at 37b46f6: the native query-type getter handles CombinedFields, but the Node factory and public TypeScript class/export are still missing.

    I would keep the Python work with you and mirror the existing MultiMatchQuery constructor shape, adding the N-API factory, public type/export, generated declarations, and docs. Validation would include a real local FTS index with terms split across title/body (AND versus MultiMatch), OR, boosts and invalid inputs, Boolean composition, and existing MultiMatch behavior. Remote serialization tests would be separate from any claim of Cloud support.

    Is that split/API shape appropriate, and is anyone already handling the TypeScript side? This preparation is AI-assisted; I have not built or tested a native implementation yet.

  3. BHAWESHBHASKAR commented on Oct 28, 2026

    @BHAWESHBHASKAR
    ContributorAuthor

    Yes, a separate TypeScript follow-up would be welcome, and nobody is handling that side as far as I know. I kept #4691 to Python on purpose, and I'm not planning a TypeScript PR.

    Your reading of main matches mine: nodejs/src/query.rs already returns "combined_fields" from the query-type getter, but there is no combined_fields_query factory next to multi_match_query, and no CombinedFieldsQuery class or export in nodejs/lancedb/query.ts and index.ts.

    Mirroring the MultiMatchQuery constructor shape (query, columns, { boosts, operator }) sounds right. Two things worth matching from the Python side: boost validation comes from Lance (one weight per column, each at least 1), so the binding only needs to pass them through; and the docs currently say Python only, so once your PR lands please update the note in docs/web/search/full-text-search.mdx and add a TypeScript tab to the combined-fields example.

    If you want, open the PR and reference this issue; I'm happy to review.

  4. added a commit that references this issue on Oct 29, 2026
    8917743
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions