googleapis / googleapis/dotnet-spanner-entity-framework

Update to EF 9.0 and use Vector Search capability

Open
#481 3 comments 4 reactions 0 assignees View on GitHub
priority: p3 type: feature request
Dominant language
C#
Stars
34
Forks
13
Avg merge
4h 39m
Merged PRs (30d)
10

Description

Thanks for stopping by to let us know something could be better!

**Is your feature request related to a problem? Please describe.**
Cloud Spanner has introduced Vector Search capabilities; which EF 9.0 now has native support for with the `IsVector` extension methods.

See: https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-9.0/whatsnew#vector-similarity-search-preview

**Describe the solution you'd like**
Be able to define a column as a `Vector` type using EF and the DDL created for Cloud Spanner marks up the ARRAY type as a Vector index.
```csharp
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity()
.Property(b => b.Embeddings)
.IsVector(DistanceFunction.Cosine, dimensions: 1536);
}
```

When using the `Where` predicate, if the operator is a Vector Search, the translated SQL statements generated are vector searches:
```csharp
var blogs = await context.Blogs
.OrderBy(s => EF.Functions.VectorDistance(s.Vector, vector))
.Take(5)
.ToListAsync();
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.