feat: add Search for vector, keyword, and hybrid search - #77
Open
lukekim wants to merge 5 commits into
Open
Conversation
Wraps POST /v1/search, which was previously unreachable from Go without hand-rolling the HTTP call. spice.js is the only other SDK that exposes it. Only Text is required; Datasets, Limit, Where, AdditionalColumns and Keywords are optional. Supplying Keywords pre-filters the embedding column with a lexical search before the vector search, making the search hybrid. Decodes the runtime's wire format directly, including the `_score` field name and the data/primary_key/metadata objects the runtime omits when empty.
The error path only unpacked a JSON {"error": ...} body and otherwise reported
a bare "failed with status=400", dropping the part that says what to fix — for
example "Search cannot be run on X because it has no embeddings or full text
search indexes", which the runtime returns as plain text.
Caught by running the new search path against a live runtime.
There was a problem hiding this comment.
Pull request overview
Adds first-class Go SDK support for the runtime’s POST /v1/search endpoint by introducing SpiceClient.Search plus request/response types, tests, and README documentation so Go users can perform vector, keyword, and hybrid search without hand-rolling HTTP.
Changes:
- Introduces
SearchRequest,SearchResponse, andSearchMatchwire-format types andSpiceClient.Searchimplementation. - Adds unit tests covering request encoding, method/path, response decoding (including omitted objects), validation, and runtime error surfacing.
- Documents
Searchusage and behavior in the README, including hybrid search viaKeywords.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| search.go | Adds SpiceClient.Search and associated request/response types plus runtime error-message handling. |
| search_test.go | Adds httptest-based unit tests for encoding/decoding, validation, and error surfacing. |
| README.md | Documents the new Search API with examples and field behavior notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…gistry `spice add spiceai/quickstart` makes every run depend on the Spicepod registry. That service is currently returning a body the CLI cannot unpack, so every job fails at: Invalid argument: Failed to extract Spicepod archive: invalid Zip archive: Could not find EOCD The runtime and the SDK are fine; only the fetch is broken. Declaring the same dataset spiceai/quickstart provides removes the dependency. Applies to both the Unix and WSL setup steps. Verified locally: taxi_trips loads and is queryable within seconds (2,964,624 rows). Mirrors spicepy#176.
…' into merge/ci-fix
An empty X-API-Key reads as a supplied-but-invalid credential to auth middleware, which behaves differently from omitting the header. IsSpiceReady already guards this; Search now matches. Addresses review feedback on #77.
3 tasks
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.
What
Adds
SpiceClient.Search, wrapping the runtime'sPOST /v1/search— vector similarity, keyword, and hybrid search over datasets with an embedding column.Only
Textis required. SettingKeywordspre-filters the embedding column with a lexical search before the vector search runs, making the search hybrid.Why
/v1/searchworks on a defaultspice runand is a distinctive Spice capability, but Go users had no way to reach it short of hand-rolling the HTTP call. spice.js is currently the only SDK that exposes it.Two wire-format details the types handle so callers don't have to:
_score, notscoredata,primary_keyandmetadataare omitted entirely when empty, so they decode tonilmaps — safe to read from in GoPart of aligning search support across the SDKs.
Verification
go build ./...go vet ./...gofmtcleango test -run TestSearch ./..., covering request encoding, method/path, response decoding (including omitted objects), validation, and runtime error surfacing. All run againsthttptest, so they need no live runtime.spice run: the search request reaches/v1/search, and afailure surfaces the runtime's own message (
"Search cannot be run on <dataset> because it has no embeddings or full text search indexes.") rather than a bare status codeembedding column and a loaded embedding model, which this environment has no credentials for