Skip to content

feat: support structured_query in the directory namespace query_table#7592

Open
hamersaw wants to merge 1 commit into
lance-format:mainfrom
hamersaw:bug/dir-namespace-fts-structured-query
Open

feat: support structured_query in the directory namespace query_table#7592
hamersaw wants to merge 1 commit into
lance-format:mainfrom
hamersaw:bug/dir-namespace-fts-structured-query

Conversation

@hamersaw

@hamersaw hamersaw commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

The directory namespace's query_table only handled string_query for full-text search — a structured_query was silently ignored, so the scan ran with no FTS filter and returned all rows. This wires structured_query through to the engine, so the local query_table path honors structured FTS the same way the JNI scanner and fragment.new_scan(full_text_query) already do. There was a literal // For now, we only support string_query TODO at the change site.

What changed

rust/lance-namespace-impls/src/dir.rs:

  • Added a structured_query branch in query_table that runs FullTextSearchQuery::new_query(...) built from the namespace model.
  • build_engine_fts_query maps models::FtsQuery → engine FtsQuery for all variants (match, phrase, multi_match, and recursively boolean/boost), mirroring the mapping in lance-jni/src/blocking_scanner.rs.
  • build_engine_match_query copies terms / column / boost / fuzziness / max_expansions / operator / prefix_length, parsing the operator string via Operator::try_from.
  • An FtsQuery with no variant set is now rejected with a clear error instead of silently ignored.
  • string_query behavior is unchanged.

Tests

Unit tests for the mapping — test_build_engine_fts_query_match (all MatchQuery options round-trip into the engine query) and test_build_engine_fts_query_requires_a_variant (empty query is rejected). cargo test -p lance-namespace-impls, cargo check -p lance-namespace-impls, and cargo fmt --check all pass.

Motivation

Downstream connectors (e.g. lance-spark) route full-text search to the namespace query_table and build the richer structured_query form (fuzziness / operator / phrase / multi_match). Against a directory namespace that dropped structured_query, those queries silently returned every row instead of filtering. This makes the dir namespace honor the structured API — which is the canonical FTS query direction (the engine's FullTextSearchQuery is structured internally; string_query is the legacy convenience form, and LanceDB's remote path already prefers structured).

🤖 Generated with Claude Code

The directory namespace's query_table only handled string_query; a
structured_query was silently ignored, so the scan ran without any full-text
filter and returned all rows. Map the namespace structured FtsQuery model
into the engine FtsQuery for all variants — match, phrase, multi_match, and
(recursively) boolean and boost — and run it via
FullTextSearchQuery::new_query, mirroring the mapping the JNI scanner already
performs. An FtsQuery with no variant set is now rejected rather than
silently ignored. string_query behavior is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added A-namespace Namespace impls enhancement New feature or request labels Jul 2, 2026
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 54.54545% with 45 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance-namespace-impls/src/dir.rs 54.54% 35 Missing and 10 partials ⚠️

📢 Thoughts on this report? Let us know!

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

Labels

A-namespace Namespace impls enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant