SqlHydra.Query.Pgvector
0.1.0-alpha.1
dotnet add package SqlHydra.Query.Pgvector --version 0.1.0-alpha.1
NuGet\Install-Package SqlHydra.Query.Pgvector -Version 0.1.0-alpha.1
<PackageReference Include="SqlHydra.Query.Pgvector" Version="0.1.0-alpha.1" />
<PackageVersion Include="SqlHydra.Query.Pgvector" Version="0.1.0-alpha.1" />
<PackageReference Include="SqlHydra.Query.Pgvector" />
paket add SqlHydra.Query.Pgvector --version 0.1.0-alpha.1
#r "nuget: SqlHydra.Query.Pgvector, 0.1.0-alpha.1"
#:package SqlHydra.Query.Pgvector@0.1.0-alpha.1
#addin nuget:?package=SqlHydra.Query.Pgvector&version=0.1.0-alpha.1&prerelease
#tool nuget:?package=SqlHydra.Query.Pgvector&version=0.1.0-alpha.1&prerelease
SqlHydra.Query.Pgvector
Vector similarity search for SqlHydra.Query, powered by pgvector.
Write select and ORDER BY queries that compare embeddings by cosine, L2
(Euclidean), or inner-product distance — all in strongly-typed F#, with the native
pgvector operators (<=>, <->, <#>) generated for you. It also teaches the SqlHydra
code generator about vector columns so they come through as Pgvector.Vector in your
generated types.
Before you start
You'll need:
- A PostgreSQL database with the pgvector
extension enabled (
CREATE EXTENSION vector;) and a table with avectorcolumn. - SqlHydra.Query set up for that database. If you're new to SqlHydra, start with its docs — this package just adds vector search on top of the queries you already write.
Installation
dotnet add package SqlHydra.Query.Pgvector
Searching by similarity
Open the package alongside SqlHydra.Query, then use the distance functions in a query.
queryVector below is your search embedding — the Pgvector.Vector you want to find the
nearest rows to.
open SqlHydra.Query
open SqlHydra.Query.Pgvector.PgvectorExtensions
open type SqlHydra.Query.Pgvector.PgvectorExtensions.PgvectorFn
// Return each document together with how far it is from your query vector:
select {
for d in documents do
select (cosine_distance (d.embedding, queryVector))
}
// Find the 10 closest documents (nearest-neighbour search):
select {
for d in documents do
orderByCosineDistance d.embedding (box queryVector)
take 10
}
That's it — no setup or registration call is required.
Available distance functions
Use these inside select to get a distance back as a column:
| Function | Distance |
|---|---|
cosine_distance(a, b) |
Cosine |
l2_distance(a, b) |
L2 / Euclidean |
inner_product_distance(a, b) |
Inner product |
Use these to order results from closest to farthest:
| Operation | Distance |
|---|---|
orderByCosineDistance col vec |
Cosine |
orderByL2Distance col vec |
L2 / Euclidean |
orderByInnerProductDistance col vec |
Inner product |
The query vector is always sent as a query parameter, so it's safe to pass user input.
Generating types for vector columns
So that SqlHydra generates a Pgvector.Vector property for each vector column, add this
package to the [extensions] section of your SqlHydra generator TOML:
[extensions]
type_mappings = ["SqlHydra.Query.Pgvector"]
Re-run dotnet sqlhydra and your vector columns will come through as Pgvector.Vector.
Building this project
Tasks are driven by mise:
mise run build # build the solution
mise run test # run all tests (the integration tests need Docker)
mise run ci # the full gate: format check + build + test
mise run format # format with Fantomas
The integration tests spin up a real PostgreSQL + pgvector container via Testcontainers, so they need a running Docker daemon. To run only the in-process unit tests without Docker:
dotnet test --solution SqlHydra.Query.Pgvector.slnx \
--filter-not-trait "Category=Integration"
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- FSharp.Core (>= 10.1.300)
- SqlHydra.Query (>= 4.1.0-beta.1)
-
net10.0
- FSharp.Core (>= 10.1.300)
- SqlHydra.Query (>= 4.1.0-beta.1)
-
net8.0
- FSharp.Core (>= 10.1.300)
- SqlHydra.Query (>= 4.1.0-beta.1)
-
net9.0
- FSharp.Core (>= 10.1.300)
- SqlHydra.Query (>= 4.1.0-beta.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-alpha.1 | 25 | 6/9/2026 |