Skip to content

Commit

Permalink
[release/9.0] Enable Cosmos vector search on EF9 (#35183)
Browse files Browse the repository at this point in the history
Replaces #35002
  • Loading branch information
ajcvickers authored Nov 27, 2024
1 parent b50581a commit 08b4d43
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 164 deletions.
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

0 comments on commit 08b4d43

Please sign in to comment.