From 939500650798fa2f81694c641e53027f06e52308 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Tue, 12 May 2026 20:17:39 +0200 Subject: [PATCH 1/2] Skip vector indexes on Linux emulator (diskANN broken) The vnext-preview Cosmos Linux emulator Docker image was updated between May 8-11, 2026. It now rejects 'flat' and 'quantizedFlat' vector index types (only 'diskANN' claimed as supported), and rejects 'uint8'/'int8' embedding data types (only 'float32'/'float16'). However, diskANN itself also doesn't work - container creation with diskANN vector indexes returns a 500 InternalServerError with PostgresError(SqlState(E42704)). This is an emulator bug. The fix: - Keep vector embedding config (IsVectorProperty) unconditionally so VectorDistance() translation is still tested - Make all vector index config (IsVectorIndex/HasVectorIndex) conditional on !TestEnvironment.IsLinuxEmulator - Make byte/sbyte embedding config conditional (unsupported data types) - Skip byte/sbyte vector tests with [CosmosCondition(IsNotLinuxEmulator)] - Change index type from Flat to DiskANN for non-emulator environments Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../HybridSearchTranslationsCosmosTest.cs | 30 +++++++++++------ .../VectorSearchTranslationsCosmosTest.cs | 32 +++++++++++++------ 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/HybridSearchTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/HybridSearchTranslationsCosmosTest.cs index 9c363ec0709..6bd8d257157 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/HybridSearchTranslationsCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/HybridSearchTranslationsCosmosTest.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Azure.Cosmos; @@ -17,6 +17,7 @@ public HybridSearchCosmosTest(HybridSearchFixture fixture, ITestOutputHelper tes protected HybridSearchFixture Fixture { get; } [ConditionalFact] + [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task Rrf_with_FullTextScore_and_VectorDistance() { await using var context = CreateContext(); @@ -40,6 +41,7 @@ ORDER BY RANK RRF(FullTextScore(c["Description"], "beaver", "otter"), VectorDist } [ConditionalFact] + [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task Rrf_with_FullTextScore_and_VectorDistance_with_weights() { await using var context = CreateContext(); @@ -129,20 +131,28 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.Property(x => x.Description).EnableFullTextSearch(); b.HasIndex(x => x.Description).IsFullTextIndex(); - b.HasIndex(e => e.Bytes).IsVectorIndex(VectorIndexType.Flat); - b.HasIndex(e => e.SBytes).IsVectorIndex(VectorIndexType.Flat); - b.HasIndex(e => e.BytesArray).IsVectorIndex(VectorIndexType.Flat); - b.HasIndex(e => e.SinglesArray).IsVectorIndex(VectorIndexType.Flat); - - b.Property(e => e.Bytes).IsVectorProperty(DistanceFunction.Cosine, 10); - b.Property(e => e.SBytes).IsVectorProperty(DistanceFunction.DotProduct, 10); - b.Property(e => e.BytesArray).IsVectorProperty(DistanceFunction.Cosine, 10); b.Property(e => e.SinglesArray).IsVectorProperty(DistanceFunction.Cosine, 10); + if (!TestEnvironment.IsLinuxEmulator) + { + b.HasIndex(e => e.SinglesArray).IsVectorIndex(VectorIndexType.DiskANN); + b.HasIndex(e => e.Bytes).IsVectorIndex(VectorIndexType.DiskANN); + b.HasIndex(e => e.SBytes).IsVectorIndex(VectorIndexType.DiskANN); + b.HasIndex(e => e.BytesArray).IsVectorIndex(VectorIndexType.DiskANN); + + b.Property(e => e.Bytes).IsVectorProperty(DistanceFunction.Cosine, 10); + b.Property(e => e.SBytes).IsVectorProperty(DistanceFunction.DotProduct, 10); + b.Property(e => e.BytesArray).IsVectorProperty(DistanceFunction.Cosine, 10); + } + b.OwnsOne( x => x.Owned, bb => { - bb.HasIndex(e => e.Singles).IsVectorIndex(VectorIndexType.Flat); + if (!TestEnvironment.IsLinuxEmulator) + { + bb.HasIndex(e => e.Singles).IsVectorIndex(VectorIndexType.DiskANN); + } + bb.Property(e => e.Singles).IsVectorProperty(DistanceFunction.Cosine, 10); bb.Property(x => x.AnotherDescription).EnableFullTextSearch(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs index feb34832ca7..7903cef76f9 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Azure.Cosmos; @@ -67,6 +67,7 @@ FROM root c } [ConditionalFact] + [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task OrderBy_VectorDistance_bytes_memory() { await using var context = CreateContext(); @@ -89,6 +90,7 @@ ORDER BY VectorDistance(c["Bytes"], @p) } [ConditionalFact] + [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task OrderBy_VectorDistance_bytes_array() { await using var context = CreateContext(); @@ -111,6 +113,7 @@ ORDER BY VectorDistance(c["BytesArray"], @p) } [ConditionalFact] + [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task OrderBy_VectorDistance_sbyte() { await using var context = CreateContext(); @@ -255,6 +258,7 @@ FROM root c } [ConditionalFact] + [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task RRF_with_two_Vector_distance_functions_in_OrderBy() { await using var context = CreateContext(); @@ -392,23 +396,31 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasKey(e => e.Id); b.HasPartitionKey(e => e.Publisher); - b.HasIndex(e => e.Bytes).IsVectorIndex(VectorIndexType.Flat); - b.HasIndex(e => e.SBytes).IsVectorIndex(VectorIndexType.Flat); - b.HasIndex(e => e.BytesArray).IsVectorIndex(VectorIndexType.Flat); - b.HasIndex(e => e.SinglesArray).IsVectorIndex(VectorIndexType.Flat); - - b.Property(e => e.Bytes).IsVectorProperty(DistanceFunction.Cosine, 10); - b.Property(e => e.SBytes).IsVectorProperty(DistanceFunction.DotProduct, 10); - b.Property(e => e.BytesArray).IsVectorProperty(DistanceFunction.Cosine, 10); b.Property(e => e.SinglesArray).IsVectorProperty(DistanceFunction.Cosine, 10); + if (!TestEnvironment.IsLinuxEmulator) + { + b.HasIndex(e => e.SinglesArray).IsVectorIndex(VectorIndexType.DiskANN); + b.HasIndex(e => e.Bytes).IsVectorIndex(VectorIndexType.DiskANN); + b.HasIndex(e => e.SBytes).IsVectorIndex(VectorIndexType.DiskANN); + b.HasIndex(e => e.BytesArray).IsVectorIndex(VectorIndexType.DiskANN); + + b.Property(e => e.Bytes).IsVectorProperty(DistanceFunction.Cosine, 10); + b.Property(e => e.SBytes).IsVectorProperty(DistanceFunction.DotProduct, 10); + b.Property(e => e.BytesArray).IsVectorProperty(DistanceFunction.Cosine, 10); + } + b.OwnsOne( x => x.OwnedReference, bb => { bb.OwnsOne( x => x.NestedOwned, bbb => { - bbb.HasIndex(x => x.NestedSingles).IsVectorIndex(VectorIndexType.Flat); + if (!TestEnvironment.IsLinuxEmulator) + { + bbb.HasIndex(x => x.NestedSingles).IsVectorIndex(VectorIndexType.DiskANN); + } + bbb.Property(x => x.NestedSingles).IsVectorProperty(DistanceFunction.Cosine, 10); }); From 190254f41f81648397bb559e1cef87e5c9a1d44d Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Tue, 12 May 2026 20:41:11 +0200 Subject: [PATCH 2/2] Skip vector/hybrid search test classes on Linux emulator The vnext-preview Cosmos Linux emulator doesn't support vector search (neither vector indexes nor byte/sbyte embedding data types), so skip the entire test classes on the Linux emulator. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../HybridSearchTranslationsCosmosTest.cs | 32 +++++++----------- .../VectorSearchTranslationsCosmosTest.cs | 33 +++++++------------ 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/HybridSearchTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/HybridSearchTranslationsCosmosTest.cs index 6bd8d257157..2bafb272bd5 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/HybridSearchTranslationsCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/HybridSearchTranslationsCosmosTest.cs @@ -1,11 +1,11 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Azure.Cosmos; namespace Microsoft.EntityFrameworkCore.Query.Translations; -[CosmosCondition(CosmosCondition.DoesNotUseTokenCredential | CosmosCondition.IsNotEmulator)] +[CosmosCondition(CosmosCondition.DoesNotUseTokenCredential | CosmosCondition.IsNotEmulator | CosmosCondition.IsNotLinuxEmulator)] public class HybridSearchCosmosTest : IClassFixture { public HybridSearchCosmosTest(HybridSearchFixture fixture, ITestOutputHelper testOutputHelper) @@ -17,7 +17,6 @@ public HybridSearchCosmosTest(HybridSearchFixture fixture, ITestOutputHelper tes protected HybridSearchFixture Fixture { get; } [ConditionalFact] - [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task Rrf_with_FullTextScore_and_VectorDistance() { await using var context = CreateContext(); @@ -41,7 +40,6 @@ ORDER BY RANK RRF(FullTextScore(c["Description"], "beaver", "otter"), VectorDist } [ConditionalFact] - [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task Rrf_with_FullTextScore_and_VectorDistance_with_weights() { await using var context = CreateContext(); @@ -131,28 +129,20 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.Property(x => x.Description).EnableFullTextSearch(); b.HasIndex(x => x.Description).IsFullTextIndex(); - b.Property(e => e.SinglesArray).IsVectorProperty(DistanceFunction.Cosine, 10); + b.HasIndex(e => e.Bytes).IsVectorIndex(VectorIndexType.Flat); + b.HasIndex(e => e.SBytes).IsVectorIndex(VectorIndexType.Flat); + b.HasIndex(e => e.BytesArray).IsVectorIndex(VectorIndexType.Flat); + b.HasIndex(e => e.SinglesArray).IsVectorIndex(VectorIndexType.Flat); - if (!TestEnvironment.IsLinuxEmulator) - { - b.HasIndex(e => e.SinglesArray).IsVectorIndex(VectorIndexType.DiskANN); - b.HasIndex(e => e.Bytes).IsVectorIndex(VectorIndexType.DiskANN); - b.HasIndex(e => e.SBytes).IsVectorIndex(VectorIndexType.DiskANN); - b.HasIndex(e => e.BytesArray).IsVectorIndex(VectorIndexType.DiskANN); - - b.Property(e => e.Bytes).IsVectorProperty(DistanceFunction.Cosine, 10); - b.Property(e => e.SBytes).IsVectorProperty(DistanceFunction.DotProduct, 10); - b.Property(e => e.BytesArray).IsVectorProperty(DistanceFunction.Cosine, 10); - } + b.Property(e => e.Bytes).IsVectorProperty(DistanceFunction.Cosine, 10); + b.Property(e => e.SBytes).IsVectorProperty(DistanceFunction.DotProduct, 10); + b.Property(e => e.BytesArray).IsVectorProperty(DistanceFunction.Cosine, 10); + b.Property(e => e.SinglesArray).IsVectorProperty(DistanceFunction.Cosine, 10); b.OwnsOne( x => x.Owned, bb => { - if (!TestEnvironment.IsLinuxEmulator) - { - bb.HasIndex(e => e.Singles).IsVectorIndex(VectorIndexType.DiskANN); - } - + bb.HasIndex(e => e.Singles).IsVectorIndex(VectorIndexType.Flat); bb.Property(e => e.Singles).IsVectorProperty(DistanceFunction.Cosine, 10); bb.Property(x => x.AnotherDescription).EnableFullTextSearch(); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs index 7903cef76f9..bb9d3131aab 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/VectorSearchTranslationsCosmosTest.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Azure.Cosmos; @@ -6,6 +6,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Translations; +[CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public class VectorSearchTranslationsCosmosTest : IClassFixture { public VectorSearchTranslationsCosmosTest(VectorSearchFixture fixture, ITestOutputHelper testOutputHelper) @@ -67,7 +68,6 @@ FROM root c } [ConditionalFact] - [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task OrderBy_VectorDistance_bytes_memory() { await using var context = CreateContext(); @@ -90,7 +90,6 @@ ORDER BY VectorDistance(c["Bytes"], @p) } [ConditionalFact] - [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task OrderBy_VectorDistance_bytes_array() { await using var context = CreateContext(); @@ -113,7 +112,6 @@ ORDER BY VectorDistance(c["BytesArray"], @p) } [ConditionalFact] - [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task OrderBy_VectorDistance_sbyte() { await using var context = CreateContext(); @@ -258,7 +256,6 @@ FROM root c } [ConditionalFact] - [CosmosCondition(CosmosCondition.IsNotLinuxEmulator)] public virtual async Task RRF_with_two_Vector_distance_functions_in_OrderBy() { await using var context = CreateContext(); @@ -396,19 +393,15 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con b.HasKey(e => e.Id); b.HasPartitionKey(e => e.Publisher); - b.Property(e => e.SinglesArray).IsVectorProperty(DistanceFunction.Cosine, 10); - - if (!TestEnvironment.IsLinuxEmulator) - { - b.HasIndex(e => e.SinglesArray).IsVectorIndex(VectorIndexType.DiskANN); - b.HasIndex(e => e.Bytes).IsVectorIndex(VectorIndexType.DiskANN); - b.HasIndex(e => e.SBytes).IsVectorIndex(VectorIndexType.DiskANN); - b.HasIndex(e => e.BytesArray).IsVectorIndex(VectorIndexType.DiskANN); + b.HasIndex(e => e.Bytes).IsVectorIndex(VectorIndexType.Flat); + b.HasIndex(e => e.SBytes).IsVectorIndex(VectorIndexType.Flat); + b.HasIndex(e => e.BytesArray).IsVectorIndex(VectorIndexType.Flat); + b.HasIndex(e => e.SinglesArray).IsVectorIndex(VectorIndexType.Flat); - b.Property(e => e.Bytes).IsVectorProperty(DistanceFunction.Cosine, 10); - b.Property(e => e.SBytes).IsVectorProperty(DistanceFunction.DotProduct, 10); - b.Property(e => e.BytesArray).IsVectorProperty(DistanceFunction.Cosine, 10); - } + b.Property(e => e.Bytes).IsVectorProperty(DistanceFunction.Cosine, 10); + b.Property(e => e.SBytes).IsVectorProperty(DistanceFunction.DotProduct, 10); + b.Property(e => e.BytesArray).IsVectorProperty(DistanceFunction.Cosine, 10); + b.Property(e => e.SinglesArray).IsVectorProperty(DistanceFunction.Cosine, 10); b.OwnsOne( x => x.OwnedReference, bb => @@ -416,11 +409,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con bb.OwnsOne( x => x.NestedOwned, bbb => { - if (!TestEnvironment.IsLinuxEmulator) - { - bbb.HasIndex(x => x.NestedSingles).IsVectorIndex(VectorIndexType.DiskANN); - } - + bbb.HasIndex(x => x.NestedSingles).IsVectorIndex(VectorIndexType.Flat); bbb.Property(x => x.NestedSingles).IsVectorProperty(DistanceFunction.Cosine, 10); });