Repository navigation
fix(faiss): keep searching when filters drop the first candidates - #4323
Merged
davidsbatista merged 4 commits intoNov 27, 2026
Merged
davidsbatista merged 4 commits into
davidsbatista merged 4 commits into
Conversation
astroknot-sheep
requested review from
davidsbatista
and removed request for
a team
November 24, 2026 09:24
Contributor
Coverage report (faiss)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
4 tasks done
Contributor
|
Thanks @astroknot-sheep I pushed two commits:
|
davidsbatista
approved these changes
Nov 27, 2026
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.
Related Issues
Proposed Changes:
With
filters,FAISSDocumentStore.search()fetchedmin(ntotal, top_k * 10)neighbours once and filtered them afterwards, so matching documents outside that window were never returned (the retriever could return[]whilefilter_documents()found matches).Now, if fewer than
top_kfetched neighbours match the filters, the search is repeated with double thek, up to the whole index. Searches without filters, and filtered searches that already gettop_kmatches in the first pass, behave exactly as before.How did you test it?
test_search_with_filters_finds_match_outside_first_candidates(the only matching document is the farthest one). It fails onmainand passes with this change.integrations/faiss:hatch run test:unit14 passed;pytest tests/test_document_store.py96 passed, 2 skipped;hatch run fmt-checkclean.search()andFAISSEmbeddingRetrievernow return['de'].Notes for the reviewer
I used AI assistance while investigating and drafting this PR. I reviewed every line and ran the tests myself.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.