Skip to content

query: add vector query post-filter - #82

Merged
Xuanwo merged 9 commits into
mainfrom
xuanwo/triage-c-query-builder-51
Nov 21, 2026
Merged

Xuanwo merged 9 commits into
mainfrom
xuanwo/triage-c-query-builder-51

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 21, 2026

Copy link
Copy Markdown
Member

Add an additive C API to run a vector query filter after the vector search, matching the Rust SDK's postfilter() behavior requested in #51.

  • New lancedb_vector_query_postfilter() on the opaque LanceDBVectorQuery. It sets prefilter = false; without calling it, the SDK default prefilter = true is preserved.
  • Applied in both lancedb_vector_query_execute and lancedb_vector_query_explain_plan, so the plan reflects the option.
  • Docs note that post-filtering can return fewer than limit rows and that refine_factor can recover some results.

Tests (Release, Arrow 26.0.1, Catch2 v2.13.10):

  • cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON
  • cmake --build build --target lancedb_vector_query_tests -j 12
  • cd build && ./lancedb_vector_query_tests -> 45019 assertions, 12 test cases passed
  • ctest -R vector_query --output-on-failure -> 1/1 passed

The new test verifies the observable result difference (pre-filter returns the far matching row; post-filter returns none from the nearest five) and that the explain plan differs between the two modes. Existing [vector_query] coverage passes unchanged.

Closes #51.

Expose lancedb_vector_query_postfilter(), mapping to the Rust SDK's postfilter() so a filter can run after the vector search. The default stays prefilter=true and the option applies to both execution and explain-plan.

Add coverage for prefilter vs postfilter row counts, explain-plan routing, and null-handle validation.
Own the postfilter flag before the explain path borrows the query into its async block, so the runtime rework can snapshot it with the other query parameters. Use single-quoted SQL literals in the new test, which both the 0.33 and 0.42 SDKs accept.
Main now propagates SQL predicates into explain plans (#84). Add a public where_filter plus postfilter explain section to the post-filter test, checking the predicate appears in both modes and the plans differ.
Xuanwo dropped Intel macOS support. Remove only the x86_64-apple-darwin matrix entry; the standalone packaging cleanup owns script and docs references.
@Xuanwo
Xuanwo merged commit dde7ebb into main Nov 21, 2026
13 checks passed
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.

support post-filter in the vector query api

1 participant