Skip to content

FTS: rows with equal _score come back in an order that changes between calls and processes; a limit inside a tie keeps arbitrary rows #4516

Open

Description

@gheylen

Versions: lancedb 0.39.0, pylance 12.0.0, pyarrow 25.0.1, Python 3.14, Linux x86-64.

Index: inverted (FTS) index, simple tokenizer, Dutch stemming, stop words removed, with_position=False, one segment, about 10.14 M documents, no unindexed rows. The table version did not change during any of the runs below.

Repro

tbl.search(q, query_type="fts").with_row_id(True).limit(64).to_arrow()

Run it three times in one process, then once each in fresh processes, and compare the row ids inside groups of rows with equal _score.

Observed over 50 queries

  • Every difference falls inside a group of rows with equal _score. No score value changes.
  • Which rows come back changes only where such a group straddles limit.
  • The first call in a process differs from the later calls, which agree with each other (39 of 50 queries).
  • Warm results match across processes only with LANCE_CPU_THREADS=1: 25 of 25 queries, against 3 of 50 at two threads. The first call in a process varies even then.
  • Inside a tie, rows are not ordered by _rowid.

Ask

A deterministic tie-break before the top-k cut (for example by row address), or documentation that the order inside a tie is unspecified.

Related

RRFReranker ranks rows by their position in each list (enumerate(ids, 1) in rerankers/rrf.py). So hybrid results inherit this: tied FTS rows get distinct fused scores in arrival order. We worked around that side by putting each list in (score, id) order before fusing.

Caveat: this was seen on a private table and has not been reduced to synthetic data yet.

Activity

  1. ahlag commented on Oct 12, 2026

    @ahlag

    This looks like the same root cause as lance-format/lance#9132, where results with the same score can get skipped or duplicated across pages. There's an open fix in lance-format/lance#7846 that breaks ties with (score DESC, row_id ASC) in the BM25 top-k collector, similar to Lucene. It still needs a rebase and has an open review. Once it lands, the tied rows would also arrive in a stable order for the RRF reranker.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions