SqlHydra.Query.Pgvector 0.1.0-alpha.1

This is a prerelease version of SqlHydra.Query.Pgvector.
dotnet add package SqlHydra.Query.Pgvector --version 0.1.0-alpha.1
                    
NuGet\Install-Package SqlHydra.Query.Pgvector -Version 0.1.0-alpha.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SqlHydra.Query.Pgvector" Version="0.1.0-alpha.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SqlHydra.Query.Pgvector" Version="0.1.0-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="SqlHydra.Query.Pgvector" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SqlHydra.Query.Pgvector --version 0.1.0-alpha.1
                    
#r "nuget: SqlHydra.Query.Pgvector, 0.1.0-alpha.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SqlHydra.Query.Pgvector@0.1.0-alpha.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SqlHydra.Query.Pgvector&version=0.1.0-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=SqlHydra.Query.Pgvector&version=0.1.0-alpha.1&prerelease
                    
Install as a Cake Tool

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 a vector column.
  • 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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