Skip to content

feat(search): infer --type and --column from indexes; default schema to public#90

Merged
eddietejeda merged 2 commits into
mainfrom
feat/search-implicit-type-column
May 20, 2026
Merged

feat(search): infer --type and --column from indexes; default schema to public#90
eddietejeda merged 2 commits into
mainfrom
feat/search-implicit-type-column

Conversation

@eddietejeda
Copy link
Copy Markdown
Contributor

@eddietejeda eddietejeda commented May 20, 2026

Summary

Makes hotdata search less verbose by inferring flags from existing indexes.

  • --type and --column are now optional. When either is omitted, the CLI calls the indexes API, filters to searchable types (bm25/vector), and resolves them. Errors clearly when ambiguous or no index exists.
  • --table now accepts connection.table as shorthand for connection.public.table (schema defaults to public).
  • --limit already defaulted to 10.

Before: hotdata search "query" --type bm25 --table airbnb.public.listings --column description --limit 5

After: hotdata search "query" --table airbnb.listings --limit 5

Test plan

  • Search with no --type or --column on a table with one BM25 index — resolves and returns results
  • Search with no --type or --column on a table with one vector index — requires embedding provider setup; covered by unit test resolve_search_params_single_vector_returns_type_and_column
  • Search on a table with multiple search indexes and no hints — errors asking to specify --type and --column
  • Search on a table with no search indexes — errors: 'No BM25 or vector index found on ... — run hotdata indexes create first.'
  • connection.table resolves to connection.public.table
  • connection.schema.table still works as before
  • All 161 tests pass (152 existing + 9 new unit tests for inference logic)

🤖 Generated with Claude Code

…to public

Make --type and --column optional in hotdata search. When either is
omitted, the CLI fetches the table indexes, filters to searchable
types (bm25/vector), and resolves them automatically. Exits with a
clear error when the result is ambiguous or no index exists.

Accept connection.table as shorthand for connection.public.table
in --table; schema defaults to public when omitted.

Before:
  hotdata search query --type bm25 --table airbnb.public.listings --column description --limit 5

After:
  hotdata search query --table airbnb.listings --limit 5

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sentry
Copy link
Copy Markdown

sentry Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 68.58974% with 49 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/main.rs 0.00% 26 Missing ⚠️
src/indexes.rs 82.30% 23 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment thread src/indexes.rs Outdated
Comment on lines +215 to +230
_ => {
let types: Vec<&str> = matches.iter().map(|i| i.index_type.as_str()).collect();
let cols: Vec<String> = matches
.iter()
.flat_map(|i| i.columns.iter().cloned())
.collect();
eprintln!(
"{}",
format!(
"Multiple search indexes found (types: {}, columns: {}) — specify --type and --column.",
types.join(", "),
cols.join(", ")
)
.red()
);
std::process::exit(1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: (not blocking) When the user already passes one of --type/--column (so hint_type or hint_column is Some) and inference still finds multiple matches, the error tells them to "specify --type and --column". They've already specified one of them — only the missing hint would help. Consider tailoring the suggestion to whichever hint is still None (e.g. "specify --column" when hint_type was provided).

claude[bot]
claude Bot previously approved these changes May 20, 2026
…r inference logic

- Extract resolve_search_params as a pure function returning Result so
  the matching logic is testable without API mocking
- Replace unwrap_or_default() on columns with ok_or_else() so an index
  with no columns produces a clear error instead of silent empty string
- Add 9 unit tests covering single bm25/vector, hint narrowing, no
  indexes, multiple indexes, hint type mismatch, and empty columns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@eddietejeda eddietejeda merged commit 3659414 into main May 20, 2026
10 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.

1 participant