Repository navigation
fix(lancedb): refresh the Tantivy FTS index so keyword_search sees later inserts - #87
Open
teddytennant wants to merge 1 commit into
Open
teddytennant wants to merge 1 commit into
teddytennant wants to merge 1 commit into
Conversation
…ter inserts The local (Tantivy) full text index was built once, on the first insert, and guarded by _fts_initialized afterwards. Tantivy indexes are snapshots, so every row added by a later insert was stored and visible to semantic and structured search but invisible to keyword_search. A table reopened by a new process carried the same gap. insert() now only marks the index stale (local storage only), and keyword_search() rebuilds it before querying when it is stale or missing. Rebuilding lazily keeps ingestion, which writes one batch per window, from paying for a rebuild on every insert. The index build and the query share a lock so concurrent searches do not rebuild or read the index mid-write. The native index used for cloud storage already searches rows added after it was created, so it is still built only once. Fixes aiming-lab#78
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.
Fixes #78
LanceDBVectorStoreBackendbuilt its Tantivy full text index once, on the first insert, and skipped it afterwards. Tantivy indexes are snapshots, so every entry added by a later insert was stored and visible to semantic and structured search but never returned bykeyword_search. Since ingestion writes one batch per window, anything past the first window was affected. A table reopened in a new process had the same gap.Changes:
insert()now only marks the index stale (local storage only).keyword_search()rebuilds the index before querying when it is stale or missing. Rebuilding lazily means ingestion doesn't pay for a rebuild on every window.gs://ors3://backend.Tests added in
tests/test_vector_store_backend.pycover entries from later inserts, reopening an existing table,clear()followed by inserts, and that rebuilds happen at search time rather than insert time. The first two and the lazy-rebuild test fail onmain.Notes:
pylanceinstalled alongside lancedb. Without it, index creation is skipped silently and keyword search returns nothing. I didn't touchrequirements.txt._fts_initializedpattern exists incross/storage_lancedb.pyand the twosimplemem-skillcopies ofvector_store.py. I kept this PR focused on the core backend and can follow up on those.