Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/9.0] Enable Cosmos vector search on EF9 #35183

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<PackageVersion Include="Microsoft.DotNet.Build.Tasks.Templating" Version="$(MicrosoftDotNetBuildTasksTemplatingVersion)" />

<!-- Azure SDK for .NET dependencies -->
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.43.0" />
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.45.2" />

<!-- SQL Server dependencies -->
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.6" />
Expand All @@ -51,14 +51,14 @@
<PackageVersion Include="NetTopologySuite.IO.SqlServerBytes" Version="2.1.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="mod_spatialite" Version="4.3.0.1" />
<PackageVersion Include="SQLitePCLRaw.core" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="SQLitePCLRaw.core" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="SQLitePCLRaw.bundle_sqlite3" Version="$(SQLitePCLRawVersion)" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="$(SQLitePCLRawVersion)" />

<!-- Pinned versions for Component Governance/NuGetAudit - Remove when root dependencies are updated -->
<!--Workaround for Microsoft.CodeAnalysis.Workspaces.MSBuild 4.8.0, see https://github.com/dotnet/efcore/issues/34637-->
<PackageVersion Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkVersion)" />
<!--Workaround for Microsoft.Data.SqlClient v5.1.6 and Microsoft.CodeAnalysis.Analyzer.Testing v1.1.2-->
<PackageVersion Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildFrameworkVersion)" />
<!--Workaround for Microsoft.Data.SqlClient v5.1.6 and Microsoft.CodeAnalysis.Analyzer.Testing v1.1.2-->
<PackageVersion Include="System.Formats.Asn1" Version="$(SystemFormatsAsn1Version)" />
</ItemGroup>
</Project>
36 changes: 0 additions & 36 deletions src/EFCore.Cosmos/Extensions/DistanceFunction.cs

This file was deleted.

19 changes: 0 additions & 19 deletions src/EFCore.Cosmos/Extensions/Embedding.cs

This file was deleted.

40 changes: 0 additions & 40 deletions src/EFCore.Cosmos/Extensions/VectorDataType.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/EFCore.Cosmos/Extensions/VectorIndexPath.cs

This file was deleted.

35 changes: 0 additions & 35 deletions src/EFCore.Cosmos/Extensions/VectorIndexType.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/EFCore.Cosmos/Properties/CosmosStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,6 @@
<data name="NoSubqueryPushdown" xml:space="preserve">
<value>Azure Cosmos DB does not have an appropriate subquery for this translation.</value>
</data>
<data name="NoVectorContainerConfig" xml:space="preserve">
<value>Container configuration for embeddings is not yet supported by the Cosmos SDK. Instead, configure the container manually. See https://aka.ms/ef-cosmos-vectors for more information.</value>
</data>
<data name="NullTypeMappingInSqlTree" xml:space="preserve">
<value>The expression '{sqlExpression}' in the SQL tree does not have a type mapping assigned.</value>
</data>
Expand Down
7 changes: 2 additions & 5 deletions src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,14 @@ private static async Task<bool> CreateContainerIfNotExistsOnceAsync(
AnalyticalStoreTimeToLiveInSeconds = parameters.AnalyticalStoreTimeToLiveInSeconds,
};

// TODO: Enable these once they are available in the Cosmos SDK. See #33783.
if (embeddings.Any())
{
throw new InvalidOperationException(CosmosStrings.NoVectorContainerConfig);
//containerProperties.VectorEmbeddingPolicy = new VectorEmbeddingPolicy(embeddings);
containerProperties.VectorEmbeddingPolicy = new VectorEmbeddingPolicy(embeddings);
}

if (vectorIndexes.Any())
{
throw new InvalidOperationException(CosmosStrings.NoVectorContainerConfig);
//containerProperties.IndexingPolicy = new IndexingPolicy { VectorIndexes = vectorIndexes };
containerProperties.IndexingPolicy = new IndexingPolicy { VectorIndexes = vectorIndexes };
}

var response = await wrapper.Client.GetDatabase(wrapper._databaseId).CreateContainerIfNotExistsAsync(
Expand Down
3 changes: 1 addition & 2 deletions test/EFCore.Cosmos.FunctionalTests/VectorSearchCosmosTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ namespace Microsoft.EntityFrameworkCore;

#pragma warning disable EF9103

// These tests are skipped for now because we cannot create a compatible test container until the SDK supports it.
internal class VectorSearchCosmosTest : IClassFixture<VectorSearchCosmosTest.VectorSearchFixture>
public class VectorSearchCosmosTest : IClassFixture<VectorSearchCosmosTest.VectorSearchFixture>
{
public VectorSearchCosmosTest(VectorSearchFixture fixture, ITestOutputHelper testOutputHelper)
{
Expand Down