You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add SearchAsync for vector, keyword, and hybrid search (#22)
* feat: add SearchAsync for vector, keyword, and hybrid search
Wraps POST /v1/search, which was previously unreachable from .NET 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.
SearchMatch maps the runtime's wire format, including the `_score` field name
and the objects the runtime omits when empty; those default to empty
dictionaries so callers can read them without a null check.
System.Text.Json was already resolved transitively via Apache.Arrow.Adbc; it is
now referenced explicitly at the version that dependency already selects, since
netstandard2.0 has no in-box System.Text.Json.
* fix: surface why authentication failed instead of a trailer error
AuthenticateAsync passed stream.GetTrailers() as an argument, so trailers were
read eagerly — before the handshake had completed. gRPC only makes trailers
available once a call finishes, so any handshake that fails throws
System.InvalidOperationException: Can't get the call trailers because the
call has not completed successfully.
which replaces the gRPC status describing the actual problem. Every integration
test in CI reports this, and it says nothing about what to fix.
Now the token is read from the response headers first, trailers are consulted
only if the headers carry none, and a failure to read them is caught rather
than propagated. The resulting SpiceException names the likely cause and
carries the originating RpcException as InnerException.
Reproduced against a TLS endpoint that is not a Flight service:
before: InvalidOperationException: Can't get the call trailers ...
after: SpiceException: Failed to authenticate: the runtime returned no
authorization token. Check that the API key is valid for this endpoint.
* fix: scope the System.Text.Json reference to netstandard2.0, name the failing member
Two issues from review:
- System.Text.Json was referenced unconditionally, pushing a dependency
constraint onto net8.0+ consumers that already have it in-box. Now
conditioned on netstandard2.0, which is the target that actually needs it.
netstandard2.0 still resolves 9.0.9, so there is no NU1605 downgrade.
- Argument validation reported nameof(request) when it was request.Text that
was empty, pointing callers at the wrong member.
Only `Text` is required. `Datasets` restricts the search — leave it unset to search every
243
+
dataset with an embedding column. `Limit` caps matches per dataset, `Where` applies an SQL
244
+
predicate before the search, and `AdditionalColumns` names extra columns to return. Setting
245
+
`Keywords` pre-filters the embedding column with a lexical search before the vector search
246
+
runs, making the search hybrid:
247
+
248
+
```csharp
249
+
varresponse=awaitclient.SearchAsync(newSearchRequest("tickets to Tokyo")
250
+
{
251
+
Where="city = 'Tokyo'",
252
+
AdditionalColumns=new[] { "timestamp" },
253
+
Keywords=new[] { "plane", "tickets" },
254
+
});
255
+
```
256
+
257
+
Each `SearchMatch` carries the `Dataset` it was found in, its similarity `Score`, the
258
+
matched column values in `Matches`, the row's `PrimaryKey`, the columns requested via
259
+
`AdditionalColumns` in `Data`, and any `Metadata`. The runtime omits the last three when
260
+
empty; they default to empty dictionaries, so they can be read without a null check.
261
+
218
262
### Memory Management
219
263
220
264
The `SpiceClient` implements `IDisposable` and should be properly disposed to release network resources (gRPC channels, HTTP clients). Use the `using` statement or `using` declaration for automatic disposal:
0 commit comments