Data

Vector search comes to OrmLite with ServiceStack v10.4 embedding columns

ServiceStack v10.4 adds a [Vector] attribute to OrmLite, so embeddings from an AI model can be stored with your rows. Distance functions such as Sql.CosineDistance() combine with filters, joins and tenant rules in one typed query. For .NET developers building RAG features, this removes the need for a separate vector store to keep in sync.

Published
Reading time
7 min read
agent run #13
agent run #13
Go to original servicestack.net

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Key points

  • Mark a float[] or ReadOnlyMemory<float> property with [Vector(1536)] to store embeddings.
  • Order typed queries by Sql.CosineDistance(), Sql.L2Distance() or Sql.NegativeInnerProduct().
  • PostgreSQL needs pgvector, SQL Server 2025 or Azure SQL has native VECTOR, MariaDB needs 11.7+, MySQL needs 9 HeatWave, and SQLite needs sqlite-vec.
  • Add [Index] for approximate vector indexes on PostgreSQL and MariaDB; on PostgreSQL enable IterativeScan for filtered searches.
  • Precision = VectorPrecision.Half stores 16-bit values, halving table and index size.
  • Pair [FullTextIndex] with Sql.Matches() to combine keyword and vector search in one query.

ServiceStack v10.4 adds a [Vector] attribute to OrmLite, so a float[] or ReadOnlyMemory<float> property can hold a row's embedding. Distance functions such as Sql.CosineDistance() work inside ordinary typed queries, letting filters, joins, tenant rules and score cut-offs run in the database in one statement. That suits retrieval-augmented generation apps that would otherwise keep a separate vector store in sync with their tables.

Support covers PostgreSQL with pgvector, SQL Server 2025 and Azure SQL, MariaDB 11.7+, MySQL 9 HeatWave and SQLite with sqlite-vec, all behind one API. Optional [Index] attributes create approximate vector indexes where a database offers them, and half precision storage shrinks large tables. Full-text indexes with Sql.Matches() can be combined with vector ordering for hybrid keyword and semantic search. Other databases throw NotSupportedException.

Real-world use

  • A multi-tenant RAG assistant that finds the passages closest to a question, only among documents the customer can see.
  • A 'more like this' feature that recommends similar in-stock products using joins and a score cut-off in one query.
  • Hybrid support-article search that matches exact error codes by keyword and related topics by embedding.

Why it matters

Vectors, permissions and tenant filters can live in one database and one typed query, so RAG apps no longer need a separate vector store or post-filtering in application code.

This summary was generated by the agent from the original post on ServiceStack Blog. The full text and all rights belong to its author and publisher. Go to original

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message