Skip to content

Implement top-k filtered search inside [Mutable]Vamana indices and orchestrators wrappers - #489

Open
rfsaliev wants to merge 16 commits into
dev/filtered-range-searchfrom
rfsaliev/filtered-search
Open

rfsaliev wants to merge 16 commits into
dev/filtered-range-searchfrom
rfsaliev/filtered-search

Conversation

@rfsaliev

@rfsaliev rfsaliev commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

TODO:

  • Tests
  • C API change

yuejiaointel and others added 15 commits November 25, 2026 06:58
Reuse the MutableBuffer valid/invalid mechanism: a FilteredValidBuilder marks an
entry invalid if it is deleted or the predicate rejects its external id. New
MutableVamanaIndex::search overload taking a predicate, padding rows with
id -1 / +inf and returning per-query found counts. Supplement path checks the
predicate before computing the distance. Orchestrator virtual appended last.

Make filtered search an optional argument of the existing search

Replace the separate filtered search overload with two optional trailing
arguments on MutableVamanaIndex::search (an id predicate and a per-query
result count). Without a predicate the existing code path runs unchanged.
check_and_supplement_search_buffer gets an optional predicate that is
checked before the distance is computed. The filter predicate type is now
a type-erased std::function, so FilteredValidBuilder is no longer a
template. The orchestrator keeps one appended virtual that forwards to the
index search.

Run filtered search through the existing batch search path

The optional filter on MutableVamanaIndex::search now only chooses which
builder the existing greedy search closure uses; both cases call the same
per_thread_batch_search. FilteredValidBuilder derives from ValidBuilder.
The buffer top-up in single_search applies the filter when the search
closure carries one. The per-query result count out-parameter is removed
(callers count non-padding ids).

per_thread_batch_search now pads result rows with fewer than k entries
(id size_t(-1), distance +inf) instead of reading past the end of the
search buffer, and the post-search id translation skips the padding.

Filter through ValidBuilder in the existing dynamic search

Give ValidBuilder an optional predicate and pass it down through
internal_search_builder, greedy_search_closure and search() as optional
arguments, instead of a separate builder and search path. Filtered-only
checks: the supplement fallback skips failing ids, copy-out pads short rows
with id -1 and the worst score, translation skips padded ids.

Fix filtered test and orchestrator for the concurrent index

The orchestrator reports filtered search as unsupported for indexes whose
search has no filter argument (the concurrent index), instead of failing to
compile. In the filtered test, drop the unfiltered-padding section (padding is
filtered-only) and add an inner-product case checking padding uses -inf.

Allow filtered search for data types that opt in

Apply clang-format

Enable filtered search for all data types

Apply clang-format

Name the filter argument `filter` everywhere

Apply clang-format

Choose the filtering builder at compile time

Remove the added filtered-search test

Share the search body between filtered and regular search

Return to the ValidBuilder design before the compile-time changes

Choose filtered or regular search at compile time

Filtered search on the concurrent index

Skip the filter for entries the buffer would drop
Clarify the ValidBuilder comment

Put the ValidBuilder comment on the class

Shorten the ValidBuilder comment

Shorten comments and drop a redundant template argument
Filtered search on the static Vamana index

Fix unused lambda capture in regular search

Fix unused lambda capture in concurrent regular search
Drop the FilteredSearch closure wrapper: single_search and per_thread_batch_search take the filter as a trailing argument and hand it to the buffer top-up. A filtered concurrent search re-checks the filter on the external ids it returns, and the filter contract is documented.
Reject the reserved external id, make the filter re-entry guard per index, mark translated ids that vanish as invalid, drop identical filtered/unfiltered branches, share the query-type dispatch for filtered_search (now void), and fix the metadata estimate comment.
@rfsaliev
rfsaliev changed the base branch from main to dev/filtered-range-search November 25, 2026 14:37
@rfsaliev
rfsaliev marked this pull request as ready for review November 25, 2026 15:57

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants