diff --git a/.github/workflows/mevd.yml b/.github/workflows/mevd.yml index ba2e6ba..5fb7471 100644 --- a/.github/workflows/mevd.yml +++ b/.github/workflows/mevd.yml @@ -155,10 +155,10 @@ jobs: fail-fast: false matrix: provider: ${{ fromJson(needs.discover.outputs.all_providers) }} - # AzureAISearch and CosmosMongoDB require cloud instances and can't run in CI. + # AzureAISearch and AzureDocumentDB require cloud instances and can't run in CI. exclude: - provider: AzureAISearch - - provider: CosmosMongoDB + - provider: AzureDocumentDB steps: - uses: actions/checkout@v6 diff --git a/CommunityToolkit.AI.slnx b/CommunityToolkit.AI.slnx index f0c7ed0..31f6e90 100644 --- a/CommunityToolkit.AI.slnx +++ b/CommunityToolkit.AI.slnx @@ -10,7 +10,7 @@ - + @@ -25,8 +25,8 @@ - - + + diff --git a/MEVD/MEVD.slnf b/MEVD/MEVD.slnf index 18885dd..c8feb37 100644 --- a/MEVD/MEVD.slnf +++ b/MEVD/MEVD.slnf @@ -5,7 +5,7 @@ [ "MEVD/src/AzureAISearch/AzureAISearch.csproj", "MEVD/src/CosmosNoSql/CosmosNoSql.csproj", - "MEVD/src/CosmosMongoDB/CosmosMongoDB.csproj", + "MEVD/src/AzureDocumentDB/AzureDocumentDB.csproj", "MEVD/src/InMemory/InMemory.csproj", "MEVD/src/PgVector/PgVector.csproj", "MEVD/src/Qdrant/Qdrant.csproj", @@ -18,8 +18,8 @@ "MEVD/test/AzureAISearch.ConformanceTests/AzureAISearch.ConformanceTests.csproj", "MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj", "MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj", - "MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoDB.UnitTests.csproj", - "MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDB.ConformanceTests.csproj", + "MEVD/test/AzureDocumentDB.UnitTests/AzureDocumentDB.UnitTests.csproj", + "MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj", "MEVD/test/InMemory.UnitTests/InMemory.UnitTests.csproj", "MEVD/test/InMemory.ConformanceTests/InMemory.ConformanceTests.csproj", "MEVD/test/PgVector.UnitTests/PgVector.UnitTests.csproj", diff --git a/MEVD/src/CosmosMongoDB/AssemblyInfo.cs b/MEVD/src/AzureDocumentDB/AssemblyInfo.cs similarity index 100% rename from MEVD/src/CosmosMongoDB/AssemblyInfo.cs rename to MEVD/src/AzureDocumentDB/AssemblyInfo.cs diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoDB.csproj b/MEVD/src/AzureDocumentDB/AzureDocumentDB.csproj similarity index 59% rename from MEVD/src/CosmosMongoDB/CosmosMongoDB.csproj rename to MEVD/src/AzureDocumentDB/AzureDocumentDB.csproj index fb19b0f..cbad69e 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoDB.csproj +++ b/MEVD/src/AzureDocumentDB/AzureDocumentDB.csproj @@ -2,17 +2,18 @@ 1.0.0 - CommunityToolkit.VectorData.CosmosMongoDB + CommunityToolkit.VectorData.AzureDocumentDB $(AssemblyName) net10.0;net8.0;netstandard2.1;net472 true - Azure CosmosDB MongoDB vCore provider for Microsoft.Extensions.VectorData - Azure CosmosDB MongoDB vCore provider for Microsoft.Extensions.VectorData by the .NET Community Toolkit + Azure DocumentDB (with MongoDB compatibility) provider for Microsoft.Extensions.VectorData + Azure DocumentDB (with MongoDB compatibility) provider for Microsoft.Extensions.VectorData by the .NET Community Toolkit + AzureDocumentDB;AzureMongoDB;CosmosMongoDB;VectorData - + diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoCollection.cs b/MEVD/src/AzureDocumentDB/DocumentDBCollection.cs similarity index 92% rename from MEVD/src/CosmosMongoDB/CosmosMongoCollection.cs rename to MEVD/src/AzureDocumentDB/DocumentDBCollection.cs index 766b533..797a8da 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoCollection.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBCollection.cs @@ -15,15 +15,15 @@ using MEVD = Microsoft.Extensions.VectorData; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// -/// Service for storing and retrieving vector records, that uses Azure CosmosDB MongoDB as the underlying storage. +/// Service for storing and retrieving vector records, that uses Azure DocumentDB as the underlying storage. /// /// The data type of the record key. Must be either . /// The data model to use for adding, updating and retrieving data from storage. #pragma warning disable CA1711 // Identifiers should not have incorrect suffix -public class CosmosMongoCollection : VectorStoreCollection +public class DocumentDBCollection : VectorStoreCollection where TKey : notnull where TRecord : class #pragma warning restore CA1711 // Identifiers should not have incorrect suffix @@ -40,10 +40,10 @@ public class CosmosMongoCollection : VectorStoreCollectionThe default options for vector search. private static readonly MEVD.VectorSearchOptions s_defaultVectorSearchOptions = new(); - /// that can be used to manage the collections in Azure CosmosDB MongoDB. + /// that can be used to manage the collections in Azure DocumentDB. private readonly IMongoDatabase _mongoDatabase; - /// Azure CosmosDB MongoDB collection to perform record operations. + /// Azure DocumentDB collection to perform record operations. private readonly IMongoCollection _mongoCollection; /// Interface for mapping between a storage model, and the consumer record data model. @@ -70,28 +70,28 @@ public class CosmosMongoCollection : VectorStoreCollection - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// that can be used to manage the collections in Azure CosmosDB MongoDB. - /// The name of the collection that this will access. + /// that can be used to manage the collections in Azure DocumentDB. + /// The name of the collection that this will access. /// Optional configuration options for this class. - [RequiresDynamicCode("This constructor is incompatible with NativeAOT. For dynamic mapping via Dictionary, instantiate CosmosMongoDynamicCollection instead.")] - [RequiresUnreferencedCode("This constructor is incompatible with trimming. For dynamic mapping via Dictionary, instantiate CosmosMongoDynamicCollection instead.")] - public CosmosMongoCollection( + [RequiresDynamicCode("This constructor is incompatible with NativeAOT. For dynamic mapping via Dictionary, instantiate DocumentDBDynamicCollection instead.")] + [RequiresUnreferencedCode("This constructor is incompatible with trimming. For dynamic mapping via Dictionary, instantiate DocumentDBDynamicCollection instead.")] + public DocumentDBCollection( IMongoDatabase mongoDatabase, string name, - CosmosMongoCollectionOptions? options = default) + DocumentDBCollectionOptions? options = default) : this( mongoDatabase, name, static options => typeof(TRecord) == typeof(Dictionary) - ? throw new NotSupportedException(VectorDataStrings.NonDynamicCollectionWithDictionaryNotSupported(typeof(CosmosMongoDynamicCollection))) + ? throw new NotSupportedException(VectorDataStrings.NonDynamicCollectionWithDictionaryNotSupported(typeof(DocumentDBDynamicCollection))) : new MongoModelBuilder().Build(typeof(TRecord), typeof(TKey), options.Definition, options.EmbeddingGenerator), options) { } - internal CosmosMongoCollection(IMongoDatabase mongoDatabase, string name, Func modelFactory, CosmosMongoCollectionOptions? options) + internal DocumentDBCollection(IMongoDatabase mongoDatabase, string name, Func modelFactory, DocumentDBCollectionOptions? options) { // Verify. Throw.IfNull(mongoDatabase); @@ -102,7 +102,7 @@ internal CosmosMongoCollection(IMongoDatabase mongoDatabase, string name, Func CosmosMongoCollectionSearchMapping.GetSearchQueryForHnswIndex( + IndexKind.Hnsw => DocumentDBCollectionSearchMapping.GetSearchQueryForHnswIndex( vector, vectorProperty.StorageName, itemsAmount, _efSearch, filter), - IndexKind.IvfFlat => CosmosMongoCollectionSearchMapping.GetSearchQueryForIvfIndex( + IndexKind.IvfFlat => DocumentDBCollectionSearchMapping.GetSearchQueryForIvfIndex( vector, vectorProperty.StorageName, itemsAmount, filter), _ => throw new InvalidOperationException( - $"Index kind '{vectorProperty.IndexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorProperty.StorageName}' is not supported by the Azure CosmosDB for MongoDB VectorStore. " + + $"Index kind '{vectorProperty.IndexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorProperty.StorageName}' is not supported by the Azure DocumentDB VectorStore. " + $"Supported index kinds are: {string.Join(", ", [IndexKind.Hnsw, IndexKind.IvfFlat])}") }; - var projectionQuery = CosmosMongoCollectionSearchMapping.GetProjectionQuery( + var projectionQuery = DocumentDBCollectionSearchMapping.GetProjectionQuery( ScorePropertyName, DocumentPropertyName); @@ -406,7 +406,7 @@ _ when vectorProperty.EmbeddingGenerationDispatcher is not null // Add score threshold filter as a $match stage if specified if (options.ScoreThreshold.HasValue) { - pipeline.Add(CosmosMongoCollectionSearchMapping.GetScoreThresholdMatchQuery(ScorePropertyName, options.ScoreThreshold.Value)); + pipeline.Add(DocumentDBCollectionSearchMapping.GetScoreThresholdMatchQuery(ScorePropertyName, options.ScoreThreshold.Value)); } const string OperationName = "Aggregate"; @@ -455,7 +455,7 @@ public override async IAsyncEnumerable GetAsync( options ??= new(); // Translate the filter now, so if it fails, we throw immediately. - var translatedFilter = new CosmosMongoFilterTranslator().Translate(filter, _model); + var translatedFilter = new DocumentDBFilterTranslator().Translate(filter, _model); SortDefinition? sortDefinition = null; var orderBy = options.OrderBy?.Invoke(new()).Values; @@ -503,13 +503,13 @@ private async Task CreateIndexesAsync(string collectionName, CancellationToken c var indexArray = new BsonArray(); - indexArray.AddRange(CosmosMongoCollectionCreateMapping.GetVectorIndexes( + indexArray.AddRange(DocumentDBCollectionCreateMapping.GetVectorIndexes( _model.VectorProperties, uniqueIndexes, _numLists, _efConstruction)); - indexArray.AddRange(CosmosMongoCollectionCreateMapping.GetFilterableDataIndexes( + indexArray.AddRange(DocumentDBCollectionCreateMapping.GetFilterableDataIndexes( _model.DataProperties, uniqueIndexes)); diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoCollectionCreateMapping.cs b/MEVD/src/AzureDocumentDB/DocumentDBCollectionCreateMapping.cs similarity index 84% rename from MEVD/src/CosmosMongoDB/CosmosMongoCollectionCreateMapping.cs rename to MEVD/src/AzureDocumentDB/DocumentDBCollectionCreateMapping.cs index 3a7a814..467368b 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoCollectionCreateMapping.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBCollectionCreateMapping.cs @@ -5,12 +5,12 @@ using Microsoft.Extensions.VectorData.ProviderServices; using MongoDB.Bson; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// -/// Contains mapping helpers to use when creating a collection in Azure CosmosDB MongoDB. +/// Contains mapping helpers to use when creating a collection in Azure DocumentDB. /// -internal static class CosmosMongoCollectionCreateMapping +internal static class DocumentDBCollectionCreateMapping { /// /// Returns an array of indexes to create for vector properties. @@ -104,25 +104,25 @@ public static BsonArray GetFilterableDataIndexes( } /// - /// More information about Azure CosmosDB for MongoDB index kinds here: . + /// More information about Azure DocumentDB index kinds here: . /// private static string GetIndexKind(string? indexKind, string vectorPropertyName) - => CosmosMongoCollectionSearchMapping.GetVectorPropertyIndexKind(indexKind) switch + => DocumentDBCollectionSearchMapping.GetVectorPropertyIndexKind(indexKind) switch { IndexKind.Hnsw => "vector-hnsw", IndexKind.IvfFlat => "vector-ivf", - _ => throw new NotSupportedException($"Index kind '{indexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB for MongoDB VectorStore.") + _ => throw new NotSupportedException($"Index kind '{indexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure DocumentDB VectorStore.") }; /// - /// More information about Azure CosmosDB for MongoDB distance functions here: . + /// More information about Azure DocumentDB distance functions here: . /// private static string GetDistanceFunction(string? distanceFunction, string vectorPropertyName) - => CosmosMongoCollectionSearchMapping.GetVectorPropertyDistanceFunction(distanceFunction) switch + => DocumentDBCollectionSearchMapping.GetVectorPropertyDistanceFunction(distanceFunction) switch { DistanceFunction.CosineDistance => "COS", DistanceFunction.DotProductSimilarity => "IP", DistanceFunction.EuclideanDistance => "L2", - _ => throw new NotSupportedException($"Distance function '{distanceFunction}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB for MongoDB VectorStore.") + _ => throw new NotSupportedException($"Distance function '{distanceFunction}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure DocumentDB VectorStore.") }; } diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoCollectionOptions.cs b/MEVD/src/AzureDocumentDB/DocumentDBCollectionOptions.cs similarity index 75% rename from MEVD/src/CosmosMongoDB/CosmosMongoCollectionOptions.cs rename to MEVD/src/AzureDocumentDB/DocumentDBCollectionOptions.cs index 0fc2d8e..c35d202 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoCollectionOptions.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBCollectionOptions.cs @@ -3,23 +3,23 @@ using Microsoft.Extensions.VectorData; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// -/// Options when creating a . +/// Options when creating a . /// -public sealed class CosmosMongoCollectionOptions : VectorStoreCollectionOptions +public sealed class DocumentDBCollectionOptions : VectorStoreCollectionOptions { - internal static readonly CosmosMongoCollectionOptions Default = new(); + internal static readonly DocumentDBCollectionOptions Default = new(); /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CosmosMongoCollectionOptions() + public DocumentDBCollectionOptions() { } - internal CosmosMongoCollectionOptions(CosmosMongoCollectionOptions? source) : base(source) + internal DocumentDBCollectionOptions(DocumentDBCollectionOptions? source) : base(source) { NumLists = source?.NumLists ?? Default.NumLists; EfConstruction = source?.EfConstruction ?? Default.EfConstruction; diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoCollectionSearchMapping.cs b/MEVD/src/AzureDocumentDB/DocumentDBCollectionSearchMapping.cs similarity index 94% rename from MEVD/src/CosmosMongoDB/CosmosMongoCollectionSearchMapping.cs rename to MEVD/src/AzureDocumentDB/DocumentDBCollectionSearchMapping.cs index 3aadb66..0e76f7a 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoCollectionSearchMapping.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBCollectionSearchMapping.cs @@ -5,12 +5,12 @@ using MongoDB.Bson; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// -/// Contains mapping helpers to use when searching for documents using Azure CosmosDB MongoDB. +/// Contains mapping helpers to use when searching for documents using Azure DocumentDB. /// -internal static class CosmosMongoCollectionSearchMapping +internal static class DocumentDBCollectionSearchMapping { /// Returns index kind specified on vector property or default . public static string GetVectorPropertyIndexKind(string? indexKind) => !string.IsNullOrWhiteSpace(indexKind) ? indexKind! : MongoConstants.DefaultIndexKind; @@ -98,7 +98,7 @@ public static BsonDocument GetProjectionQuery(string scorePropertyName, string d /// Returns a $match stage to filter results by score threshold. /// - /// Cosmos MongoDB returns a similarity score where higher values mean more similar, + /// Azure DocumentDB returns a similarity score where higher values mean more similar, /// so we filter with $gte to keep results at or above the threshold. /// public static BsonDocument GetScoreThresholdMatchQuery(string scorePropertyName, double scoreThreshold) diff --git a/MEVD/src/AzureDocumentDB/DocumentDBConstants.cs b/MEVD/src/AzureDocumentDB/DocumentDBConstants.cs new file mode 100644 index 0000000..1373e9e --- /dev/null +++ b/MEVD/src/AzureDocumentDB/DocumentDBConstants.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + + +namespace CommunityToolkit.VectorData.AzureDocumentDB; + +internal static class DocumentDBConstants +{ + public const string VectorStoreSystemName = "azure.documentdb"; +} diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoDynamicCollection.cs b/MEVD/src/AzureDocumentDB/DocumentDBDynamicCollection.cs similarity index 75% rename from MEVD/src/CosmosMongoDB/CosmosMongoDynamicCollection.cs rename to MEVD/src/AzureDocumentDB/DocumentDBDynamicCollection.cs index b5b9a7d..2bb1d7c 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoDynamicCollection.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBDynamicCollection.cs @@ -4,22 +4,22 @@ using MongoDB.Driver; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// /// Represents a collection of vector store records in a Mongo database, mapped to a dynamic Dictionary<string, object?>. /// #pragma warning disable CA1711 // Identifiers should not have incorrect suffix -public sealed class CosmosMongoDynamicCollection : CosmosMongoCollection> +public sealed class DocumentDBDynamicCollection : DocumentDBCollection> #pragma warning restore CA1711 // Identifiers should not have incorrect suffix { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// that can be used to manage the collections in MongoDB. /// The name of the collection. /// Optional configuration options for this class. - public CosmosMongoDynamicCollection(IMongoDatabase mongoDatabase, string name, CosmosMongoCollectionOptions options) + public DocumentDBDynamicCollection(IMongoDatabase mongoDatabase, string name, DocumentDBCollectionOptions options) : base( mongoDatabase, name, diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoFilterTranslator.cs b/MEVD/src/AzureDocumentDB/DocumentDBFilterTranslator.cs similarity index 96% rename from MEVD/src/CosmosMongoDB/CosmosMongoFilterTranslator.cs rename to MEVD/src/AzureDocumentDB/DocumentDBFilterTranslator.cs index d3dc9e4..c648f32 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoFilterTranslator.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBFilterTranslator.cs @@ -8,11 +8,11 @@ using Microsoft.Extensions.VectorData.ProviderServices.Filter; using MongoDB.Bson; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; // MongoDB query reference: https://www.mongodb.com/docs/manual/reference/operator/query // Information specific to vector search pre-filter: https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#atlas-vector-search-pre-filter -internal class CosmosMongoFilterTranslator : FilterTranslatorBase +internal class DocumentDBFilterTranslator : FilterTranslatorBase { internal BsonDocument Translate(LambdaExpression lambdaExpression, CollectionModel model) { @@ -63,7 +63,7 @@ private BsonDocument GenerateEqualityComparison(PropertyModel property, object? { if (value is null) { - throw new NotSupportedException("MongogDB does not support null checks in vector search pre-filters"); + throw new NotSupportedException("Azure DocumentDB does not support null checks in vector search pre-filters"); } // Short form of equality (instead of $eq) @@ -142,7 +142,7 @@ private BsonDocument TranslateNot(UnaryExpression not) return new BsonDocument { [fieldName] = new BsonDocument { ["$nin"] = values } }; } - throw new NotSupportedException("MongogDB does not support the NOT operator in vector search pre-filters"); + throw new NotSupportedException("Azure DocumentDB does not support the NOT operator in vector search pre-filters"); } private BsonDocument TranslateMethodCall(MethodCallExpression methodCall) diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoServiceCollectionExtensions.cs b/MEVD/src/AzureDocumentDB/DocumentDBServiceCollectionExtensions.cs similarity index 63% rename from MEVD/src/CosmosMongoDB/CosmosMongoServiceCollectionExtensions.cs rename to MEVD/src/AzureDocumentDB/DocumentDBServiceCollectionExtensions.cs index 3035de2..dee80ba 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoServiceCollectionExtensions.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBServiceCollectionExtensions.cs @@ -4,167 +4,167 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.AI; using Microsoft.Extensions.VectorData; -using CommunityToolkit.VectorData.CosmosMongoDB; +using CommunityToolkit.VectorData.AzureDocumentDB; using MongoDB.Driver; using Microsoft.Shared.Diagnostics; namespace Microsoft.Extensions.DependencyInjection; /// -/// Extension methods to register Azure CosmosDB MongoDB instances on an . +/// Extension methods to register Azure DocumentDB instances on an . /// -public static class CosmosMongoServiceCollectionExtensions +public static class DocumentDBServiceCollectionExtensions { private const string DynamicCodeMessage = "This method is incompatible with NativeAOT, consult the documentation for adding collections in a way that's compatible with NativeAOT."; private const string UnreferencedCodeMessage = "This method is incompatible with trimming, consult the documentation for adding collections in a way that's compatible with NativeAOT."; private const string ApplicationId = "CommunityToolkit.MEVD"; /// - /// Registers a as + /// Registers a as /// with retrieved from the dependency injection container. /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosMongoVectorStore( + public static IServiceCollection AddDocumentDBVectorStore( this IServiceCollection services, - CosmosMongoVectorStoreOptions? options = default, + DocumentDBVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) - => AddKeyedCosmosMongoVectorStore(services, serviceKey: null, options, lifetime); + => AddKeyedDocumentDBVectorStore(services, serviceKey: null, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// with retrieved from the dependency injection container. /// - /// The to register the on. + /// The to register the on. /// The key with which to associate the vector store. - /// Optional options to further configure the . + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosMongoVectorStore( + public static IServiceCollection AddKeyedDocumentDBVectorStore( this IServiceCollection services, object? serviceKey, - CosmosMongoVectorStoreOptions? options = default, + DocumentDBVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) { Throw.IfNull(services); - services.Add(new ServiceDescriptor(typeof(CosmosMongoVectorStore), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(DocumentDBVectorStore), serviceKey, (sp, _) => { var database = sp.GetRequiredService(); options = GetStoreOptions(sp, _ => options); - return new CosmosMongoVectorStore(database, options); + return new DocumentDBVectorStore(database, options); }, lifetime)); services.Add(new ServiceDescriptor(typeof(VectorStore), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); return services; } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosMongoVectorStore( + public static IServiceCollection AddDocumentDBVectorStore( this IServiceCollection services, string connectionString, string databaseName, - CosmosMongoVectorStoreOptions? options = default, + DocumentDBVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) - => AddKeyedCosmosMongoVectorStore(services, serviceKey: null, connectionString, databaseName, options, lifetime); + => AddKeyedDocumentDBVectorStore(services, serviceKey: null, connectionString, databaseName, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// - /// The to register the on. + /// The to register the on. /// The key with which to associate the vector store. - /// Connection string required to connect to Azure CosmosDB MongoDB. - /// Database name for Azure CosmosDB MongoDB. - /// Optional options to further configure the . + /// Connection string required to connect to Azure DocumentDB. + /// Database name for Azure DocumentDB. + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosMongoVectorStore( + public static IServiceCollection AddKeyedDocumentDBVectorStore( this IServiceCollection services, object? serviceKey, string connectionString, string databaseName, - CosmosMongoVectorStoreOptions? options = default, + DocumentDBVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) { Throw.IfNull(services); Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); - services.Add(new ServiceDescriptor(typeof(CosmosMongoVectorStore), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(DocumentDBVectorStore), serviceKey, (sp, _) => { options = GetStoreOptions(sp, _ => options); MongoClient mongoClient = new(CreateClientSettings(connectionString)); var database = mongoClient.GetDatabase(databaseName); - return new CosmosMongoVectorStore(database, options); + return new DocumentDBVectorStore(database, options); }, lifetime)); services.Add(new ServiceDescriptor(typeof(VectorStore), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService(key), lifetime)); return services; } /// - /// Registers a as + /// Registers a as /// with retrieved from the dependency injection container. /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosMongoCollection( + public static IServiceCollection AddDocumentDBCollection( this IServiceCollection services, string name, - CosmosMongoCollectionOptions? options = default, + DocumentDBCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TRecord : class - => AddKeyedCosmosMongoCollection(services, serviceKey: null, name, options, lifetime); + => AddKeyedDocumentDBCollection(services, serviceKey: null, name, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// with retrieved from the dependency injection container. /// /// The type of the record. - /// The to register the on. + /// The to register the on. /// The key with which to associate the collection. /// The name of the collection. - /// Optional options to further configure the . + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosMongoCollection( + public static IServiceCollection AddKeyedDocumentDBCollection( this IServiceCollection services, object? serviceKey, string name, - CosmosMongoCollectionOptions? options = default, + DocumentDBCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TRecord : class { Throw.IfNull(services); Throw.IfNullOrWhitespace(name); - services.Add(new ServiceDescriptor(typeof(CosmosMongoCollection), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(DocumentDBCollection), serviceKey, (sp, _) => { var database = sp.GetRequiredService(); options = GetCollectionOptions(sp, _ => options); - return new CosmosMongoCollection(database, name, options); + return new DocumentDBCollection(database, name, options); }, lifetime)); AddAbstractions(services, serviceKey, lifetime); @@ -173,72 +173,72 @@ public static IServiceCollection AddKeyedCosmosMongoCollection( } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddCosmosMongoCollection( + public static IServiceCollection AddDocumentDBCollection( this IServiceCollection services, string name, string connectionString, string databaseName, - CosmosMongoCollectionOptions? options = default, + DocumentDBCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TRecord : class - => AddKeyedCosmosMongoCollection(services, serviceKey: null, name, connectionString, databaseName, options, lifetime); + => AddKeyedDocumentDBCollection(services, serviceKey: null, name, connectionString, databaseName, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// /// The type of the record. - /// The to register the on. + /// The to register the on. /// The key with which to associate the collection. /// The name of the collection. - /// Connection string required to connect to Azure CosmosDB MongoDB. - /// Database name for Azure CosmosDB MongoDB. - /// Optional options to further configure the . + /// Connection string required to connect to Azure DocumentDB. + /// Database name for Azure DocumentDB. + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddKeyedCosmosMongoCollection( + public static IServiceCollection AddKeyedDocumentDBCollection( this IServiceCollection services, object? serviceKey, string name, string connectionString, string databaseName, - CosmosMongoCollectionOptions? options = default, + DocumentDBCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TRecord : class { Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); - return AddKeyedCosmosMongoCollection(services, serviceKey, name, _ => connectionString, _ => databaseName, _ => options!, lifetime); + return AddKeyedDocumentDBCollection(services, serviceKey, name, _ => connectionString, _ => databaseName, _ => options!, lifetime); } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddCosmosMongoCollection( + public static IServiceCollection AddDocumentDBCollection( this IServiceCollection services, string name, Func connectionStringProvider, Func databaseNameProvider, - Func? optionsProvider = default, + Func? optionsProvider = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TRecord : class - => AddKeyedCosmosMongoCollection(services, serviceKey: null, name, connectionStringProvider, databaseNameProvider, optionsProvider, lifetime); + => AddKeyedDocumentDBCollection(services, serviceKey: null, name, connectionStringProvider, databaseNameProvider, optionsProvider, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// /// The type of the record. @@ -252,13 +252,13 @@ public static IServiceCollection AddCosmosMongoCollection( /// Service collection. [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddKeyedCosmosMongoCollection( + public static IServiceCollection AddKeyedDocumentDBCollection( this IServiceCollection services, object? serviceKey, string name, Func connectionStringProvider, Func databaseNameProvider, - Func? optionsProvider = default, + Func? optionsProvider = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TRecord : class { @@ -267,13 +267,13 @@ public static IServiceCollection AddKeyedCosmosMongoCollection( Throw.IfNull(connectionStringProvider); Throw.IfNull(databaseNameProvider); - services.Add(new ServiceDescriptor(typeof(CosmosMongoCollection), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(DocumentDBCollection), serviceKey, (sp, _) => { var options = GetCollectionOptions(sp, optionsProvider); MongoClient mongoClient = new(CreateClientSettings(connectionStringProvider(sp))); var database = mongoClient.GetDatabase(databaseNameProvider(sp)); - return new CosmosMongoCollection(database, name, options); + return new DocumentDBCollection(database, name, options); }, lifetime)); AddAbstractions(services, serviceKey, lifetime); @@ -286,16 +286,16 @@ private static void AddAbstractions(IServiceCollection services, where TRecord : class { services.Add(new ServiceDescriptor(typeof(VectorStoreCollection), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); services.Add(new ServiceDescriptor(typeof(IVectorSearchable), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); - // Once HybridSearch supports get implemented by CosmosMongoCollection, + // Once HybridSearch supports get implemented by DocumentDBCollection, // we need to add IKeywordHybridSearchable abstraction here as well. } - private static CosmosMongoVectorStoreOptions? GetStoreOptions(IServiceProvider sp, Func? optionsProvider) + private static DocumentDBVectorStoreOptions? GetStoreOptions(IServiceProvider sp, Func? optionsProvider) { var options = optionsProvider?.Invoke(sp); if (options?.EmbeddingGenerator is not null) @@ -309,7 +309,7 @@ private static void AddAbstractions(IServiceCollection services, : new(options) { EmbeddingGenerator = embeddingGenerator }; // Create a brand new copy in order to avoid modifying the original options. } - private static CosmosMongoCollectionOptions? GetCollectionOptions(IServiceProvider sp, Func? optionsProvider) + private static DocumentDBCollectionOptions? GetCollectionOptions(IServiceProvider sp, Func? optionsProvider) { var options = optionsProvider?.Invoke(sp); if (options?.EmbeddingGenerator is not null) diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoVectorStore.cs b/MEVD/src/AzureDocumentDB/DocumentDBVectorStore.cs similarity index 80% rename from MEVD/src/CosmosMongoDB/CosmosMongoVectorStore.cs rename to MEVD/src/AzureDocumentDB/DocumentDBVectorStore.cs index 4d4b66f..a92609e 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoVectorStore.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBVectorStore.cs @@ -10,20 +10,20 @@ using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// -/// Class for accessing the list of collections in a Azure CosmosDB MongoDB vector store. +/// Class for accessing the list of collections in a Azure DocumentDB vector store. /// /// /// This class can be used with collections of any schema type, but requires you to provide schema information when getting a collection. /// -public sealed class CosmosMongoVectorStore : VectorStore +public sealed class DocumentDBVectorStore : VectorStore { /// Metadata about vector store. private readonly VectorStoreMetadata _metadata; - /// that can be used to manage the collections in Azure CosmosDB MongoDB. + /// that can be used to manage the collections in Azure DocumentDB. private readonly IMongoDatabase _mongoDatabase; /// A general purpose definition that can be used to construct a collection when needing to proxy schema agnostic operations. @@ -32,11 +32,11 @@ public sealed class CosmosMongoVectorStore : VectorStore private readonly IEmbeddingGenerator? _embeddingGenerator; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// that can be used to manage the collections in Azure CosmosDB MongoDB. + /// that can be used to manage the collections in Azure DocumentDB. /// Optional configuration options for this class. - public CosmosMongoVectorStore(IMongoDatabase mongoDatabase, CosmosMongoVectorStoreOptions? options = default) + public DocumentDBVectorStore(IMongoDatabase mongoDatabase, DocumentDBVectorStoreOptions? options = default) { Throw.IfNull(mongoDatabase); @@ -45,7 +45,7 @@ public CosmosMongoVectorStore(IMongoDatabase mongoDatabase, CosmosMongoVectorSto _metadata = new() { - VectorStoreSystemName = CosmosMongoConstants.VectorStoreSystemName, + VectorStoreSystemName = DocumentDBConstants.VectorStoreSystemName, VectorStoreName = mongoDatabase.DatabaseNamespace?.DatabaseName }; } @@ -53,15 +53,15 @@ public CosmosMongoVectorStore(IMongoDatabase mongoDatabase, CosmosMongoVectorSto #pragma warning disable IDE0090 // Use 'new(...)' /// [RequiresDynamicCode("This overload of GetCollection() is incompatible with NativeAOT. For dynamic mapping via Dictionary, call GetDynamicCollection() instead.")] - [RequiresUnreferencedCode("This overload of GetCollecttion() is incompatible with trimming. For dynamic mapping via Dictionary, call GetDynamicCollection() instead.")] + [RequiresUnreferencedCode("This overload of GetCollection() is incompatible with trimming. For dynamic mapping via Dictionary, call GetDynamicCollection() instead.")] #if NET - public override CosmosMongoCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) + public override DocumentDBCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) #else public override VectorStoreCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) #endif => typeof(TRecord) == typeof(Dictionary) ? throw new ArgumentException(VectorDataStrings.GetCollectionWithDictionaryNotSupported) - : new CosmosMongoCollection( + : new DocumentDBCollection( _mongoDatabase, name, new() @@ -72,11 +72,11 @@ public override VectorStoreCollection GetCollection #if NET - public override CosmosMongoDynamicCollection GetDynamicCollection(string name, VectorStoreCollectionDefinition definition) + public override DocumentDBDynamicCollection GetDynamicCollection(string name, VectorStoreCollectionDefinition definition) #else public override VectorStoreCollection> GetDynamicCollection(string name, VectorStoreCollectionDefinition definition) #endif - => new CosmosMongoDynamicCollection( + => new DocumentDBDynamicCollection( _mongoDatabase, name, new() diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoVectorStoreOptions.cs b/MEVD/src/AzureDocumentDB/DocumentDBVectorStoreOptions.cs similarity index 58% rename from MEVD/src/CosmosMongoDB/CosmosMongoVectorStoreOptions.cs rename to MEVD/src/AzureDocumentDB/DocumentDBVectorStoreOptions.cs index 50e8a69..6c86ad7 100644 --- a/MEVD/src/CosmosMongoDB/CosmosMongoVectorStoreOptions.cs +++ b/MEVD/src/AzureDocumentDB/DocumentDBVectorStoreOptions.cs @@ -3,21 +3,21 @@ using Microsoft.Extensions.AI; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// -/// Options when creating a +/// Options when creating a /// -public sealed class CosmosMongoVectorStoreOptions +public sealed class DocumentDBVectorStoreOptions { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CosmosMongoVectorStoreOptions() + public DocumentDBVectorStoreOptions() { } - internal CosmosMongoVectorStoreOptions(CosmosMongoVectorStoreOptions? source) + internal DocumentDBVectorStoreOptions(DocumentDBVectorStoreOptions? source) { EmbeddingGenerator = source?.EmbeddingGenerator; } diff --git a/MEVD/src/CosmosMongoDB/MongoShared/BsonValueFactory.cs b/MEVD/src/AzureDocumentDB/MongoShared/BsonValueFactory.cs similarity index 95% rename from MEVD/src/CosmosMongoDB/MongoShared/BsonValueFactory.cs rename to MEVD/src/AzureDocumentDB/MongoShared/BsonValueFactory.cs index 7837ed1..b6e3d2a 100644 --- a/MEVD/src/CosmosMongoDB/MongoShared/BsonValueFactory.cs +++ b/MEVD/src/AzureDocumentDB/MongoShared/BsonValueFactory.cs @@ -6,7 +6,7 @@ using System.Linq; using MongoDB.Bson; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// /// A class that constructs the correct BsonValue for a given CLR type. diff --git a/MEVD/src/CosmosMongoDB/MongoShared/ErrorHandlingAsyncCursor.cs b/MEVD/src/AzureDocumentDB/MongoShared/ErrorHandlingAsyncCursor.cs similarity index 97% rename from MEVD/src/CosmosMongoDB/MongoShared/ErrorHandlingAsyncCursor.cs rename to MEVD/src/AzureDocumentDB/MongoShared/ErrorHandlingAsyncCursor.cs index ff30423..38590c2 100644 --- a/MEVD/src/CosmosMongoDB/MongoShared/ErrorHandlingAsyncCursor.cs +++ b/MEVD/src/AzureDocumentDB/MongoShared/ErrorHandlingAsyncCursor.cs @@ -7,7 +7,7 @@ using Microsoft.Extensions.VectorData; using MongoDB.Driver; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// /// A decorator for that handles errors on move next. diff --git a/MEVD/src/CosmosMongoDB/MongoShared/IMongoMapper.cs b/MEVD/src/AzureDocumentDB/MongoShared/IMongoMapper.cs similarity index 92% rename from MEVD/src/CosmosMongoDB/MongoShared/IMongoMapper.cs rename to MEVD/src/AzureDocumentDB/MongoShared/IMongoMapper.cs index 1d4363c..31e23fc 100644 --- a/MEVD/src/CosmosMongoDB/MongoShared/IMongoMapper.cs +++ b/MEVD/src/AzureDocumentDB/MongoShared/IMongoMapper.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.AI; using MongoDB.Bson; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; internal interface IMongoMapper { diff --git a/MEVD/src/CosmosMongoDB/MongoShared/MongoConstants.cs b/MEVD/src/AzureDocumentDB/MongoShared/MongoConstants.cs similarity index 97% rename from MEVD/src/CosmosMongoDB/MongoShared/MongoConstants.cs rename to MEVD/src/AzureDocumentDB/MongoShared/MongoConstants.cs index de970a2..88f5d86 100644 --- a/MEVD/src/CosmosMongoDB/MongoShared/MongoConstants.cs +++ b/MEVD/src/AzureDocumentDB/MongoShared/MongoConstants.cs @@ -6,7 +6,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.VectorData; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// /// Constants for MongoDB vector store implementation. diff --git a/MEVD/src/CosmosMongoDB/MongoShared/MongoDynamicMapper.cs b/MEVD/src/AzureDocumentDB/MongoShared/MongoDynamicMapper.cs similarity index 99% rename from MEVD/src/CosmosMongoDB/MongoShared/MongoDynamicMapper.cs rename to MEVD/src/AzureDocumentDB/MongoShared/MongoDynamicMapper.cs index c959e6e..d86faba 100644 --- a/MEVD/src/CosmosMongoDB/MongoShared/MongoDynamicMapper.cs +++ b/MEVD/src/AzureDocumentDB/MongoShared/MongoDynamicMapper.cs @@ -12,7 +12,7 @@ using Microsoft.Shared.Diagnostics; using MongoDB.Bson; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// /// A mapper that maps between the dynamic data model and the model that the data is stored under, within MongoDB. diff --git a/MEVD/src/CosmosMongoDB/MongoShared/MongoMapper.cs b/MEVD/src/AzureDocumentDB/MongoShared/MongoMapper.cs similarity index 99% rename from MEVD/src/CosmosMongoDB/MongoShared/MongoMapper.cs rename to MEVD/src/AzureDocumentDB/MongoShared/MongoMapper.cs index 2e26256..1afe8bf 100644 --- a/MEVD/src/CosmosMongoDB/MongoShared/MongoMapper.cs +++ b/MEVD/src/AzureDocumentDB/MongoShared/MongoMapper.cs @@ -14,7 +14,7 @@ using MongoDB.Bson.Serialization.Conventions; using MongoDB.Bson.Serialization.Serializers; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; internal sealed class MongoMapper : IMongoMapper where TRecord : class diff --git a/MEVD/src/CosmosMongoDB/MongoShared/MongoModelBuilder.cs b/MEVD/src/AzureDocumentDB/MongoShared/MongoModelBuilder.cs similarity index 98% rename from MEVD/src/CosmosMongoDB/MongoShared/MongoModelBuilder.cs rename to MEVD/src/AzureDocumentDB/MongoShared/MongoModelBuilder.cs index 4cbcbb6..a690e64 100644 --- a/MEVD/src/CosmosMongoDB/MongoShared/MongoModelBuilder.cs +++ b/MEVD/src/AzureDocumentDB/MongoShared/MongoModelBuilder.cs @@ -11,7 +11,7 @@ using MongoDB.Bson; using MongoDB.Bson.Serialization.Attributes; -namespace CommunityToolkit.VectorData.CosmosMongoDB; +namespace CommunityToolkit.VectorData.AzureDocumentDB; /// /// Customized MongoDB model builder that adds specialized configuration of property storage names diff --git a/MEVD/src/AzureDocumentDB/MongoShared/README.md b/MEVD/src/AzureDocumentDB/MongoShared/README.md new file mode 100644 index 0000000..08c0da8 --- /dev/null +++ b/MEVD/src/AzureDocumentDB/MongoShared/README.md @@ -0,0 +1,5 @@ +# MongoShared + +These files are derived from the MongoDB vector store provider utilities. + +MongoDB now maintains its provider separately at https://github.com/mongodb/mongo-mevd-provider/tree/main/src/MongoDB. Periodically compare these files with that repository and sync relevant changes when needed. diff --git a/MEVD/src/CosmosMongoDB/README.md b/MEVD/src/AzureDocumentDB/README.md similarity index 86% rename from MEVD/src/CosmosMongoDB/README.md rename to MEVD/src/AzureDocumentDB/README.md index 74f64b5..b4dc388 100644 --- a/MEVD/src/CosmosMongoDB/README.md +++ b/MEVD/src/AzureDocumentDB/README.md @@ -1,4 +1,4 @@ -# CommunityToolkit.VectorData.CosmosMongoDB +# CommunityToolkit.VectorData.AzureDocumentDB Azure DocumentDB (with MongoDB compatibility) provider for [Microsoft.Extensions.VectorData](https://learn.microsoft.com/dotnet/ai/vector-stores/overview), by the .NET Community Toolkit. @@ -11,7 +11,7 @@ Azure DocumentDB (with MongoDB compatibility) provider for [Microsoft.Extensions 2. Install the NuGet package: ```bash -dotnet add package CommunityToolkit.VectorData.CosmosMongoDB +dotnet add package CommunityToolkit.VectorData.AzureDocumentDB ``` For more information, see the [Microsoft.Extensions.VectorData documentation](https://learn.microsoft.com/dotnet/ai/vector-stores/overview). diff --git a/MEVD/src/CosmosMongoDB/CosmosMongoConstants.cs b/MEVD/src/CosmosMongoDB/CosmosMongoConstants.cs deleted file mode 100644 index 83dd2e9..0000000 --- a/MEVD/src/CosmosMongoDB/CosmosMongoConstants.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - - -namespace CommunityToolkit.VectorData.CosmosMongoDB; - -internal static class CosmosMongoConstants -{ - public const string VectorStoreSystemName = "azure.cosmosdbmongodb"; -} diff --git a/MEVD/src/CosmosMongoDB/MongoShared/README.md b/MEVD/src/CosmosMongoDB/MongoShared/README.md deleted file mode 100644 index 1af63ff..0000000 --- a/MEVD/src/CosmosMongoDB/MongoShared/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# MongoShared - -These files are shared utilities that are identical across the Cosmos MongoDB and the regular MongoDB vector store providers. - -If a regular MongoDB provider is added in the future, these files should be extracted to a shared location and linked into both projects. diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDB.ConformanceTests.csproj b/MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj similarity index 88% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDB.ConformanceTests.csproj rename to MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj index 2cd96f4..03ee156 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDB.ConformanceTests.csproj +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj @@ -6,7 +6,7 @@ enable true false - CosmosMongoDB.ConformanceTests + AzureDocumentDB.ConformanceTests b7762d10-e29b-4bb1-8b74-b6d69a667dd4 @@ -18,7 +18,7 @@ - + diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoBsonMappingTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBBsonMappingTests.cs similarity index 80% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoBsonMappingTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBBsonMappingTests.cs index cec9022..d85f399 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoBsonMappingTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBBsonMappingTests.cs @@ -1,22 +1,22 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using Microsoft.Extensions.VectorData; -using CommunityToolkit.VectorData.CosmosMongoDB; +using CommunityToolkit.VectorData.AzureDocumentDB; using MongoDB.Bson.Serialization.Attributes; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosMongoDB.ConformanceTests; +namespace AzureDocumentDB.ConformanceTests; -public sealed class CosmosMongoBsonMappingTests(CosmosMongoBsonMappingTests.Fixture fixture) - : IClassFixture +public sealed class DocumentDBBsonMappingTests(DocumentDBBsonMappingTests.Fixture fixture) + : IClassFixture { [Fact] public async Task Upsert_with_bson_model_works() { - var store = (CosmosMongoTestStore)fixture.TestStore; + var store = (DocumentDBTestStore)fixture.TestStore; var collectionName = fixture.TestStore.AdjustCollectionName("BsonModel"); var definition = new VectorStoreCollectionDefinition @@ -30,7 +30,7 @@ public async Task Upsert_with_bson_model_works() var model = new BsonTestModel { Id = "key", HotelName = "Test Name" }; - using var collection = new CosmosMongoCollection( + using var collection = new DocumentDBCollection( store.Database, collectionName, new() { Definition = definition }); @@ -55,12 +55,12 @@ public async Task Upsert_with_bson_model_works() [Fact] public async Task Upsert_with_bson_vector_store_model_works() { - var store = (CosmosMongoTestStore)fixture.TestStore; + var store = (DocumentDBTestStore)fixture.TestStore; var collectionName = fixture.TestStore.AdjustCollectionName("BsonVectorStoreModel"); var model = new BsonVectorStoreTestModel { HotelId = "key", HotelName = "Test Name" }; - using var collection = new CosmosMongoCollection(store.Database, collectionName); + using var collection = new DocumentDBCollection(store.Database, collectionName); await collection.EnsureCollectionExistsAsync(); @@ -82,12 +82,12 @@ public async Task Upsert_with_bson_vector_store_model_works() [Fact] public async Task Upsert_with_bson_vector_store_with_name_model_works() { - var store = (CosmosMongoTestStore)fixture.TestStore; + var store = (DocumentDBTestStore)fixture.TestStore; var collectionName = fixture.TestStore.AdjustCollectionName("BsonVectorStoreWithNameModel"); var model = new BsonVectorStoreWithNameTestModel { Id = "key", HotelName = "Test Name" }; - using var collection = new CosmosMongoCollection(store.Database, collectionName); + using var collection = new DocumentDBCollection(store.Database, collectionName); await collection.EnsureCollectionExistsAsync(); @@ -108,7 +108,7 @@ public async Task Upsert_with_bson_vector_store_with_name_model_works() public sealed class Fixture : VectorStoreFixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; } private sealed class BsonTestModel diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoCollectionManagementTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBCollectionManagementTests.cs similarity index 58% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoCollectionManagementTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBCollectionManagementTests.cs index c7955e9..226d961 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoCollectionManagementTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBCollectionManagementTests.cs @@ -1,13 +1,13 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using VectorData.ConformanceTests; using Xunit; -namespace CosmosMongoDB.ConformanceTests; +namespace AzureDocumentDB.ConformanceTests; -public class CosmosMongoCollectionManagementTests(CosmosMongoFixture fixture) - : CollectionManagementTests(fixture), IClassFixture +public class DocumentDBCollectionManagementTests(DocumentDBFixture fixture) + : CollectionManagementTests(fixture), IClassFixture { } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDependencyInjectionTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBDependencyInjectionTests.cs similarity index 68% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDependencyInjectionTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBDependencyInjectionTests.cs index 1b2317d..f5694f9 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDependencyInjectionTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBDependencyInjectionTests.cs @@ -3,15 +3,15 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using CommunityToolkit.VectorData.CosmosMongoDB; +using CommunityToolkit.VectorData.AzureDocumentDB; using MongoDB.Driver; using VectorData.ConformanceTests; using Xunit; -namespace CosmosMongoDB.ConformanceTests; +namespace AzureDocumentDB.ConformanceTests; -public class CosmosMongoDependencyInjectionTests - : DependencyInjectionTests.Record>, string, DependencyInjectionTests.Record> +public class DocumentDBDependencyInjectionTests + : DependencyInjectionTests.Record>, string, DependencyInjectionTests.Record> { protected const string ConnectionString = "mongodb://localhost:27017"; protected const string DatabaseName = "dbName"; @@ -19,21 +19,21 @@ public class CosmosMongoDependencyInjectionTests protected override void PopulateConfiguration(ConfigurationManager configuration, object? serviceKey = null) => configuration.AddInMemoryCollection( [ - new(CreateConfigKey("CosmosMongo", serviceKey, "ConnectionString"), ConnectionString), - new(CreateConfigKey("CosmosMongo", serviceKey, "DatabaseName"), DatabaseName), + new(CreateConfigKey("AzureDocumentDB", serviceKey, "ConnectionString"), ConnectionString), + new(CreateConfigKey("AzureDocumentDB", serviceKey, "DatabaseName"), DatabaseName), ]); private static string ConnectionStringProvider(IServiceProvider sp) - => sp.GetRequiredService().GetRequiredSection("CosmosMongo:ConnectionString").Value!; + => sp.GetRequiredService().GetRequiredSection("AzureDocumentDB:ConnectionString").Value!; private static string ConnectionStringProvider(IServiceProvider sp, object serviceKey) - => sp.GetRequiredService().GetRequiredSection(CreateConfigKey("CosmosMongo", serviceKey, "ConnectionString")).Value!; + => sp.GetRequiredService().GetRequiredSection(CreateConfigKey("AzureDocumentDB", serviceKey, "ConnectionString")).Value!; private static string DatabaseNameProvider(IServiceProvider sp) - => sp.GetRequiredService().GetRequiredSection("CosmosMongo:DatabaseName").Value!; + => sp.GetRequiredService().GetRequiredSection("AzureDocumentDB:DatabaseName").Value!; private static string DatabaseNameProvider(IServiceProvider sp, object serviceKey) - => sp.GetRequiredService().GetRequiredSection(CreateConfigKey("CosmosMongo", serviceKey, "DatabaseName")).Value!; + => sp.GetRequiredService().GetRequiredSection(CreateConfigKey("AzureDocumentDB", serviceKey, "DatabaseName")).Value!; public override IEnumerable> CollectionDelegates { @@ -43,22 +43,22 @@ private static string DatabaseNameProvider(IServiceProvider sp, object serviceKe ? services .AddSingleton(sp => new MongoClient(MongoClientSettings.FromConnectionString(ConnectionString))) .AddSingleton(sp => sp.GetRequiredService().GetDatabase(DatabaseName)) - .AddCosmosMongoCollection(name, lifetime: lifetime) + .AddDocumentDBCollection(name, lifetime: lifetime) : services .AddSingleton(sp => new MongoClient(MongoClientSettings.FromConnectionString(ConnectionString))) .AddSingleton(sp => sp.GetRequiredService().GetDatabase(DatabaseName)) - .AddKeyedCosmosMongoCollection(serviceKey, name, lifetime: lifetime); + .AddKeyedDocumentDBCollection(serviceKey, name, lifetime: lifetime); yield return (services, serviceKey, name, lifetime) => serviceKey is null - ? services.AddCosmosMongoCollection( + ? services.AddDocumentDBCollection( name, ConnectionString, DatabaseName, lifetime: lifetime) - : services.AddKeyedCosmosMongoCollection( + : services.AddKeyedDocumentDBCollection( serviceKey, name, ConnectionString, DatabaseName, lifetime: lifetime); yield return (services, serviceKey, name, lifetime) => serviceKey is null - ? services.AddCosmosMongoCollection( + ? services.AddDocumentDBCollection( name, ConnectionStringProvider, DatabaseNameProvider, lifetime: lifetime) - : services.AddKeyedCosmosMongoCollection( + : services.AddKeyedDocumentDBCollection( serviceKey, name, sp => ConnectionStringProvider(sp, serviceKey), sp => DatabaseNameProvider(sp, serviceKey), lifetime: lifetime); } } @@ -68,20 +68,20 @@ private static string DatabaseNameProvider(IServiceProvider sp, object serviceKe get { yield return (services, serviceKey, lifetime) => serviceKey is null - ? services.AddCosmosMongoVectorStore( + ? services.AddDocumentDBVectorStore( ConnectionString, DatabaseName, lifetime: lifetime) - : services.AddKeyedCosmosMongoVectorStore( + : services.AddKeyedDocumentDBVectorStore( serviceKey, ConnectionString, DatabaseName, lifetime: lifetime); yield return (services, serviceKey, lifetime) => serviceKey is null ? services .AddSingleton(sp => new MongoClient(MongoClientSettings.FromConnectionString(ConnectionString))) .AddSingleton(sp => sp.GetRequiredService().GetDatabase(DatabaseName)) - .AddCosmosMongoVectorStore(lifetime: lifetime) + .AddDocumentDBVectorStore(lifetime: lifetime) : services .AddSingleton(sp => new MongoClient(MongoClientSettings.FromConnectionString(ConnectionString))) .AddSingleton(sp => sp.GetRequiredService().GetDatabase(DatabaseName)) - .AddKeyedCosmosMongoVectorStore(serviceKey, lifetime: lifetime); + .AddKeyedDocumentDBVectorStore(serviceKey, lifetime: lifetime); } } @@ -90,9 +90,9 @@ public void ConnectionStringProviderCantBeNull() { IServiceCollection services = new ServiceCollection(); - Assert.Throws(() => services.AddCosmosMongoCollection( + Assert.Throws(() => services.AddDocumentDBCollection( name: "notNull", connectionStringProvider: null!, databaseNameProvider: DatabaseNameProvider)); - Assert.Throws(() => services.AddKeyedCosmosMongoCollection( + Assert.Throws(() => services.AddKeyedDocumentDBCollection( serviceKey: "notNull", name: "notNull", connectionStringProvider: null!, databaseNameProvider: DatabaseNameProvider)); } @@ -101,9 +101,9 @@ public void DatabaseNameProviderCantBeNull() { IServiceCollection services = new ServiceCollection(); - Assert.Throws(() => services.AddCosmosMongoCollection( + Assert.Throws(() => services.AddDocumentDBCollection( name: "notNull", connectionStringProvider: ConnectionStringProvider, databaseNameProvider: null!)); - Assert.Throws(() => services.AddKeyedCosmosMongoCollection( + Assert.Throws(() => services.AddKeyedDocumentDBCollection( serviceKey: "notNull", name: "notNull", connectionStringProvider: ConnectionStringProvider, databaseNameProvider: null!)); } @@ -112,15 +112,15 @@ public void ConnectionStringCantBeNullOrEmpty() { IServiceCollection services = new ServiceCollection(); - Assert.Throws(() => services.AddCosmosMongoVectorStore(connectionString: null!, DatabaseName)); - Assert.Throws(() => services.AddKeyedCosmosMongoVectorStore(serviceKey: "notNull", connectionString: null!, DatabaseName)); - Assert.Throws(() => services.AddCosmosMongoCollection( + Assert.Throws(() => services.AddDocumentDBVectorStore(connectionString: null!, DatabaseName)); + Assert.Throws(() => services.AddKeyedDocumentDBVectorStore(serviceKey: "notNull", connectionString: null!, DatabaseName)); + Assert.Throws(() => services.AddDocumentDBCollection( name: "notNull", connectionString: null!, DatabaseName)); - Assert.Throws(() => services.AddCosmosMongoCollection( + Assert.Throws(() => services.AddDocumentDBCollection( name: "notNull", connectionString: "", DatabaseName)); - Assert.Throws(() => services.AddKeyedCosmosMongoCollection( + Assert.Throws(() => services.AddKeyedDocumentDBCollection( serviceKey: "notNull", name: "notNull", connectionString: null!, DatabaseName)); - Assert.Throws(() => services.AddKeyedCosmosMongoCollection( + Assert.Throws(() => services.AddKeyedDocumentDBCollection( serviceKey: "notNull", name: "notNull", connectionString: "", DatabaseName)); } @@ -129,15 +129,15 @@ public void DatabaseNameCantBeNullOrEmpty() { IServiceCollection services = new ServiceCollection(); - Assert.Throws(() => services.AddCosmosMongoVectorStore(ConnectionString, databaseName: null!)); - Assert.Throws(() => services.AddKeyedCosmosMongoVectorStore(serviceKey: "notNull", ConnectionString, databaseName: null!)); - Assert.Throws(() => services.AddCosmosMongoCollection( + Assert.Throws(() => services.AddDocumentDBVectorStore(ConnectionString, databaseName: null!)); + Assert.Throws(() => services.AddKeyedDocumentDBVectorStore(serviceKey: "notNull", ConnectionString, databaseName: null!)); + Assert.Throws(() => services.AddDocumentDBCollection( name: "notNull", ConnectionString, databaseName: null!)); - Assert.Throws(() => services.AddCosmosMongoCollection( + Assert.Throws(() => services.AddDocumentDBCollection( name: "notNull", ConnectionString, databaseName: "")); - Assert.Throws(() => services.AddKeyedCosmosMongoCollection( + Assert.Throws(() => services.AddKeyedDocumentDBCollection( serviceKey: "notNull", name: "notNull", ConnectionString, databaseName: null!)); - Assert.Throws(() => services.AddKeyedCosmosMongoCollection( + Assert.Throws(() => services.AddKeyedDocumentDBCollection( serviceKey: "notNull", name: "notNull", ConnectionString, databaseName: "")); } } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDistanceFunctionTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBDistanceFunctionTests.cs similarity index 72% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDistanceFunctionTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBDistanceFunctionTests.cs index 7b1cf5a..ac8d25f 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoDistanceFunctionTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBDistanceFunctionTests.cs @@ -1,16 +1,16 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using Microsoft.Extensions.VectorData; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosMongoDB.ConformanceTests; +namespace AzureDocumentDB.ConformanceTests; -public class CosmosMongoDistanceFunctionTests(CosmosMongoDistanceFunctionTests.Fixture fixture) - : DistanceFunctionTests(fixture), IClassFixture +public class DocumentDBDistanceFunctionTests(DocumentDBDistanceFunctionTests.Fixture fixture) + : DistanceFunctionTests(fixture), IClassFixture { public override Task CosineSimilarity() => Assert.ThrowsAsync(base.CosineSimilarity); public override Task EuclideanSquaredDistance() => Assert.ThrowsAsync(base.EuclideanSquaredDistance); @@ -18,14 +18,14 @@ public class CosmosMongoDistanceFunctionTests(CosmosMongoDistanceFunctionTests.F public override Task HammingDistance() => Assert.ThrowsAsync(base.HammingDistance); public override Task ManhattanDistance() => Assert.ThrowsAsync(base.ManhattanDistance); - // CosmosMongo EuclideanDistance doesn't correctly filter by score threshold (returns all results). + // AzureDocumentDB EuclideanDistance doesn't correctly filter by score threshold (returns all results). // See https://github.com/CommunityToolkit/AI/issues/6. protected override Task TestScoreThreshold(VectorStoreCollection.SearchRecord> collection) => Task.CompletedTask; public new class Fixture() : DistanceFunctionTests.Fixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; public override bool AssertScores { get; } = false; } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoEmbeddingGenerationTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBEmbeddingGenerationTests.cs similarity index 52% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoEmbeddingGenerationTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBEmbeddingGenerationTests.cs index 88d7714..e3ba8ec 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoEmbeddingGenerationTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBEmbeddingGenerationTests.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using Microsoft.Extensions.AI; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.VectorData; @@ -9,52 +9,52 @@ using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosMongoDB.ConformanceTests; +namespace AzureDocumentDB.ConformanceTests; -public class CosmosMongoEmbeddingGenerationTests(CosmosMongoEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, CosmosMongoEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture) - : EmbeddingGenerationTests(stringVectorFixture, romOfFloatVectorFixture), IClassFixture, IClassFixture +public class DocumentDBEmbeddingGenerationTests(DocumentDBEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, DocumentDBEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture) + : EmbeddingGenerationTests(stringVectorFixture, romOfFloatVectorFixture), IClassFixture, IClassFixture { public new class StringVectorFixture : EmbeddingGenerationTests.StringVectorFixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator) - => CosmosMongoTestStore.Instance.GetVectorStore(new() { EmbeddingGenerator = embeddingGenerator }); + => DocumentDBTestStore.Instance.GetVectorStore(new() { EmbeddingGenerator = embeddingGenerator }); public override Func[] DependencyInjectionStoreRegistrationDelegates => [ services => services - .AddSingleton(CosmosMongoTestStore.Instance.Database) - .AddCosmosMongoVectorStore() + .AddSingleton(DocumentDBTestStore.Instance.Database) + .AddDocumentDBVectorStore() ]; public override Func[] DependencyInjectionCollectionRegistrationDelegates => [ services => services - .AddSingleton(CosmosMongoTestStore.Instance.Database) - .AddCosmosMongoCollection(this.CollectionName) + .AddSingleton(DocumentDBTestStore.Instance.Database) + .AddDocumentDBCollection(this.CollectionName) ]; } public new class RomOfFloatVectorFixture : EmbeddingGenerationTests.RomOfFloatVectorFixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator) - => CosmosMongoTestStore.Instance.GetVectorStore(new() { EmbeddingGenerator = embeddingGenerator }); + => DocumentDBTestStore.Instance.GetVectorStore(new() { EmbeddingGenerator = embeddingGenerator }); public override Func[] DependencyInjectionStoreRegistrationDelegates => [ services => services - .AddSingleton(CosmosMongoTestStore.Instance.Database) - .AddCosmosMongoVectorStore() + .AddSingleton(DocumentDBTestStore.Instance.Database) + .AddDocumentDBVectorStore() ]; public override Func[] DependencyInjectionCollectionRegistrationDelegates => [ services => services - .AddSingleton(CosmosMongoTestStore.Instance.Database) - .AddCosmosMongoCollection(this.CollectionName) + .AddSingleton(DocumentDBTestStore.Instance.Database) + .AddDocumentDBCollection(this.CollectionName) ]; } } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoFilterTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBFilterTests.cs similarity index 89% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoFilterTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBFilterTests.cs index 31e841e..7206a68 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoFilterTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBFilterTests.cs @@ -1,15 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosMongoDB.ConformanceTests; +namespace AzureDocumentDB.ConformanceTests; -public class CosmosMongoFilterTests(CosmosMongoFilterTests.Fixture fixture) - : FilterTests(fixture), IClassFixture +public class DocumentDBFilterTests(DocumentDBFilterTests.Fixture fixture) + : FilterTests(fixture), IClassFixture { // Specialized MongoDB syntax for NOT over Contains ($nin) [Fact] @@ -58,7 +58,7 @@ public override Task Contains_over_field_string_List() #region Enumerable.Any / Contains - // CosmosMongo filter translator doesn't support Enumerable.Any or Enumerable.Contains/MemoryExtensions.Contains + // AzureDocumentDB filter translator doesn't support Enumerable.Any or Enumerable.Contains/MemoryExtensions.Contains public override Task Any_with_Contains_over_inline_string_array() => Assert.ThrowsAsync(() => base.Any_with_Contains_over_inline_string_array()); @@ -86,7 +86,7 @@ public override Task Contains_with_MemoryExtensions_Contains_with_null_comparer( public new class Fixture : FilterTests.Fixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; protected override string IndexKind => Microsoft.Extensions.VectorData.IndexKind.IvfFlat; protected override string DistanceFunction => Microsoft.Extensions.VectorData.DistanceFunction.CosineDistance; diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoIndexKindTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBIndexKindTests.cs similarity index 56% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoIndexKindTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBIndexKindTests.cs index 10b6904..bda2267 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoIndexKindTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBIndexKindTests.cs @@ -1,18 +1,18 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using Microsoft.Extensions.VectorData; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosMongoDB.ConformanceTests; +namespace AzureDocumentDB.ConformanceTests; -public class CosmosMongoIndexKindTests(CosmosMongoIndexKindTests.Fixture fixture) - : IndexKindTests(fixture), IClassFixture +public class DocumentDBIndexKindTests(DocumentDBIndexKindTests.Fixture fixture) + : IndexKindTests(fixture), IClassFixture { - // Note: Cosmos Mongo support HNSW, but only in a specific tier. + // Note: Azure DocumentDB supports HNSW, but only in a specific tier. // [Fact] // public virtual Task Hnsw() // => this.Test(IndexKind.Hnsw); @@ -21,11 +21,11 @@ public class CosmosMongoIndexKindTests(CosmosMongoIndexKindTests.Fixture fixture public virtual Task IvfFlat() => this.Test(IndexKind.IvfFlat); - // Cosmos Mongo does not support index-less searching + // Azure DocumentDB does not support index-less searching public override Task Flat() => Assert.ThrowsAsync(base.Flat); public new class Fixture() : IndexKindTests.Fixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; } } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoTestSuiteImplementationTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBTestSuiteImplementationTests.cs similarity index 76% rename from MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoTestSuiteImplementationTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBTestSuiteImplementationTests.cs index ab421b4..9e051c0 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/CosmosMongoTestSuiteImplementationTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/DocumentDBTestSuiteImplementationTests.cs @@ -4,9 +4,9 @@ using VectorData.ConformanceTests; using VectorData.ConformanceTests.ModelTests; -namespace CosmosMongoDB.ConformanceTests; +namespace AzureDocumentDB.ConformanceTests; -public class CosmosMongoTestSuiteImplementationTests : TestSuiteImplementationTests +public class DocumentDBTestSuiteImplementationTests : TestSuiteImplementationTests { protected override ICollection IgnoredTestBases { get; } = [ diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBBasicModelTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBBasicModelTests.cs new file mode 100644 index 0000000..9d0cd5e --- /dev/null +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBBasicModelTests.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureDocumentDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureDocumentDB.ConformanceTests.ModelTests; + +public class DocumentDBBasicModelTests(DocumentDBBasicModelTests.Fixture fixture) + : BasicModelTests(fixture), IClassFixture +{ + public new class Fixture : BasicModelTests.Fixture + { + public override TestStore TestStore => DocumentDBTestStore.Instance; + } +} diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBMultiVectorModelTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBMultiVectorModelTests.cs new file mode 100644 index 0000000..bc5822c --- /dev/null +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBMultiVectorModelTests.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureDocumentDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureDocumentDB.ConformanceTests.ModelTests; + +public class DocumentDBMultiVectorModelTests(DocumentDBMultiVectorModelTests.Fixture fixture) + : MultiVectorModelTests(fixture), IClassFixture +{ + public new class Fixture : MultiVectorModelTests.Fixture + { + public override TestStore TestStore => DocumentDBTestStore.Instance; + } +} diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBNoDataModelTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBNoDataModelTests.cs new file mode 100644 index 0000000..d7a9a41 --- /dev/null +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBNoDataModelTests.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureDocumentDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureDocumentDB.ConformanceTests.ModelTests; + +public class DocumentDBNoDataModelTests(DocumentDBNoDataModelTests.Fixture fixture) + : NoDataModelTests(fixture), IClassFixture +{ + public new class Fixture : NoDataModelTests.Fixture + { + public override TestStore TestStore => DocumentDBTestStore.Instance; + } +} diff --git a/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBNoVectorModelTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBNoVectorModelTests.cs new file mode 100644 index 0000000..22c837b --- /dev/null +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/ModelTests/DocumentDBNoVectorModelTests.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureDocumentDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureDocumentDB.ConformanceTests.ModelTests; + +public class DocumentDBNoVectorModelTests(DocumentDBNoVectorModelTests.Fixture fixture) + : NoVectorModelTests(fixture), IClassFixture +{ + public new class Fixture : NoVectorModelTests.Fixture + { + public override TestStore TestStore => DocumentDBTestStore.Instance; + } +} diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/Properties/AssemblyAttributes.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Properties/AssemblyAttributes.cs similarity index 100% rename from MEVD/test/CosmosMongoDB.ConformanceTests/Properties/AssemblyAttributes.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/Properties/AssemblyAttributes.cs diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoFixture.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBFixture.cs similarity index 51% rename from MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoFixture.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBFixture.cs index ed82665..aee72ef 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoFixture.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBFixture.cs @@ -3,9 +3,9 @@ using VectorData.ConformanceTests.Support; -namespace CosmosMongoDB.ConformanceTests.Support; +namespace AzureDocumentDB.ConformanceTests.Support; -public class CosmosMongoFixture : VectorStoreFixture +public class DocumentDBFixture : VectorStoreFixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoTestEnvironment.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestEnvironment.cs similarity index 72% rename from MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoTestEnvironment.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestEnvironment.cs index 5e7ab5a..404c7d1 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoTestEnvironment.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestEnvironment.cs @@ -3,25 +3,25 @@ using Microsoft.Extensions.Configuration; -namespace CosmosMongoDB.ConformanceTests.Support; +namespace AzureDocumentDB.ConformanceTests.Support; #pragma warning disable CA1810 // Initialize all static fields when those fields are declared -public static class CosmosMongoTestEnvironment +public static class DocumentDBTestEnvironment { public static readonly string? ConnectionString; public static bool IsConnectionStringDefined => ConnectionString is not null; - static CosmosMongoTestEnvironment() + static DocumentDBTestEnvironment() { var configuration = new ConfigurationBuilder() .AddJsonFile(path: "testsettings.json", optional: true) .AddJsonFile(path: "testsettings.development.json", optional: true) .AddEnvironmentVariables() - .AddUserSecrets() + .AddUserSecrets() .Build(); - ConnectionString = configuration["CosmosMongo:ConnectionString"]; + ConnectionString = configuration["AzureDocumentDB:ConnectionString"]; } } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoTestStore.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs similarity index 61% rename from MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoTestStore.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs index 89224e7..8983043 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/Support/CosmosMongoTestStore.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/Support/DocumentDBTestStore.cs @@ -1,17 +1,17 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CommunityToolkit.VectorData.CosmosMongoDB; +using CommunityToolkit.VectorData.AzureDocumentDB; using MongoDB.Driver; using VectorData.ConformanceTests.Support; -namespace CosmosMongoDB.ConformanceTests.Support; +namespace AzureDocumentDB.ConformanceTests.Support; #pragma warning disable CA1001 -public sealed class CosmosMongoTestStore : TestStore +public sealed class DocumentDBTestStore : TestStore #pragma warning restore CA1001 { - public static CosmosMongoTestStore Instance { get; } = new(); + public static DocumentDBTestStore Instance { get; } = new(); private MongoClient? _client; private IMongoDatabase? _database; @@ -23,23 +23,23 @@ public sealed class CosmosMongoTestStore : TestStore public override string DefaultDistanceFunction => Microsoft.Extensions.VectorData.DistanceFunction.CosineDistance; - public CosmosMongoVectorStore GetVectorStore(CosmosMongoVectorStoreOptions options) + public DocumentDBVectorStore GetVectorStore(DocumentDBVectorStoreOptions options) => new(this.Database, options); - private CosmosMongoTestStore() + private DocumentDBTestStore() { } protected override Task StartAsync() { - if (string.IsNullOrWhiteSpace(CosmosMongoTestEnvironment.ConnectionString)) + if (string.IsNullOrWhiteSpace(DocumentDBTestEnvironment.ConnectionString)) { - throw new InvalidOperationException("Connection string is not configured, set the CosmosMongo:ConnectionString environment variable"); + throw new InvalidOperationException("Connection string is not configured, set the AzureDocumentDB:ConnectionString environment variable"); } - this._client = new MongoClient(CosmosMongoTestEnvironment.ConnectionString); + this._client = new MongoClient(DocumentDBTestEnvironment.ConnectionString); this._database = this._client.GetDatabase("VectorSearchTests"); - this.DefaultVectorStore = new CosmosMongoVectorStore(this._database); + this.DefaultVectorStore = new DocumentDBVectorStore(this._database); return Task.CompletedTask; } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoDataTypeTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBDataTypeTests.cs similarity index 87% rename from MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoDataTypeTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBDataTypeTests.cs index f526284..c341351 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoDataTypeTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBDataTypeTests.cs @@ -1,15 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; -namespace CosmosMongoDB.ConformanceTests.TypeTests; +namespace AzureDocumentDB.ConformanceTests.TypeTests; -public class CosmosMongoDataTypeTests(CosmosMongoDataTypeTests.Fixture fixture) - : DataTypeTests.DefaultRecord>(fixture), IClassFixture +public class DocumentDBDataTypeTests(DocumentDBDataTypeTests.Fixture fixture) + : DataTypeTests.DefaultRecord>(fixture), IClassFixture { public override Task Decimal() => this.Test( @@ -37,7 +37,7 @@ public override Task DateTimeOffset() public new class Fixture : DataTypeTests.DefaultRecord>.Fixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; // MongoDB does not support null checks in vector search pre-filters public override bool IsNullFilteringSupported => false; diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoEmbeddingTypeTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBEmbeddingTypeTests.cs similarity index 52% rename from MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoEmbeddingTypeTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBEmbeddingTypeTests.cs index 2bf7550..be121e2 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoEmbeddingTypeTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBEmbeddingTypeTests.cs @@ -1,20 +1,20 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; #pragma warning disable CA2000 // Dispose objects before losing scope -namespace CosmosMongoDB.ConformanceTests.TypeTests; +namespace AzureDocumentDB.ConformanceTests.TypeTests; -public class CosmosMongoEmbeddingTypeTests(CosmosMongoEmbeddingTypeTests.Fixture fixture) - : EmbeddingTypeTests(fixture), IClassFixture +public class DocumentDBEmbeddingTypeTests(DocumentDBEmbeddingTypeTests.Fixture fixture) + : EmbeddingTypeTests(fixture), IClassFixture { public new class Fixture : EmbeddingTypeTests.Fixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; } } diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoKeyTypeTests.cs b/MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBKeyTypeTests.cs similarity index 67% rename from MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoKeyTypeTests.cs rename to MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBKeyTypeTests.cs index d7c22ff..980d4d8 100644 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/TypeTests/CosmosMongoKeyTypeTests.cs +++ b/MEVD/test/AzureDocumentDB.ConformanceTests/TypeTests/DocumentDBKeyTypeTests.cs @@ -1,16 +1,16 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosMongoDB.ConformanceTests.Support; +using AzureDocumentDB.ConformanceTests.Support; using MongoDB.Bson; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; -namespace CosmosMongoDB.ConformanceTests.TypeTests; +namespace AzureDocumentDB.ConformanceTests.TypeTests; -public class CosmosMongoKeyTypeTests(CosmosMongoKeyTypeTests.Fixture fixture) - : KeyTypeTests(fixture), IClassFixture +public class DocumentDBKeyTypeTests(DocumentDBKeyTypeTests.Fixture fixture) + : KeyTypeTests(fixture), IClassFixture { [Fact] public virtual Task ObjectId() => this.Test(new("652f8c3e8f9b2c1a4d3e6a7b"), supportsAutoGeneration: true); @@ -26,6 +26,6 @@ public class CosmosMongoKeyTypeTests(CosmosMongoKeyTypeTests.Fixture fixture) public new class Fixture : KeyTypeTests.Fixture { - public override TestStore TestStore => CosmosMongoTestStore.Instance; + public override TestStore TestStore => DocumentDBTestStore.Instance; } } diff --git a/MEVD/test/CosmosMongoDB.UnitTests/.editorconfig b/MEVD/test/AzureDocumentDB.UnitTests/.editorconfig similarity index 100% rename from MEVD/test/CosmosMongoDB.UnitTests/.editorconfig rename to MEVD/test/AzureDocumentDB.UnitTests/.editorconfig diff --git a/MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoDB.UnitTests.csproj b/MEVD/test/AzureDocumentDB.UnitTests/AzureDocumentDB.UnitTests.csproj similarity index 73% rename from MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoDB.UnitTests.csproj rename to MEVD/test/AzureDocumentDB.UnitTests/AzureDocumentDB.UnitTests.csproj index 25007ca..bd59fc3 100644 --- a/MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoDB.UnitTests.csproj +++ b/MEVD/test/AzureDocumentDB.UnitTests/AzureDocumentDB.UnitTests.csproj @@ -1,8 +1,8 @@  - CommunityToolkit.VectorData.CosmosMongoDB.UnitTests - CommunityToolkit.VectorData.CosmosMongoDB.UnitTests + CommunityToolkit.VectorData.AzureDocumentDB.UnitTests + CommunityToolkit.VectorData.AzureDocumentDB.UnitTests net10.0 true enable @@ -21,7 +21,7 @@ - + diff --git a/MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoCollectionTests.cs b/MEVD/test/AzureDocumentDB.UnitTests/DocumentDBCollectionTests.cs similarity index 91% rename from MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoCollectionTests.cs rename to MEVD/test/AzureDocumentDB.UnitTests/DocumentDBCollectionTests.cs index 80d12cf..954d11a 100644 --- a/MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoCollectionTests.cs +++ b/MEVD/test/AzureDocumentDB.UnitTests/DocumentDBCollectionTests.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.VectorData; -using CommunityToolkit.VectorData.CosmosMongoDB; +using CommunityToolkit.VectorData.AzureDocumentDB; using MongoDB.Bson; using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Attributes; @@ -17,17 +17,17 @@ using Xunit; using MEVD = Microsoft.Extensions.VectorData; -namespace CosmosMongoDB.UnitTests; +namespace AzureDocumentDB.UnitTests; /// -/// Unit tests for class. +/// Unit tests for class. /// -public sealed class CosmosMongoCollectionTests +public sealed class DocumentDBCollectionTests { private readonly Mock _mockMongoDatabase = new(); private readonly Mock> _mockMongoCollection = new(); - public CosmosMongoCollectionTests() + public DocumentDBCollectionTests() { this._mockMongoDatabase .Setup(l => l.GetCollection(It.IsAny(), It.IsAny())) @@ -38,7 +38,7 @@ public CosmosMongoCollectionTests() public void ConstructorForModelWithoutKeyThrowsException() { // Act & Assert - var exception = Assert.Throws(() => new CosmosMongoCollection(this._mockMongoDatabase.Object, "collection")); + var exception = Assert.Throws(() => new DocumentDBCollection(this._mockMongoDatabase.Object, "collection")); Assert.Contains("No key property found", exception.Message); } @@ -46,7 +46,7 @@ public void ConstructorForModelWithoutKeyThrowsException() public void ConstructorWithDeclarativeModelInitializesCollection() { // Act & Assert - using var collection = new CosmosMongoCollection( + using var collection = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -63,7 +63,7 @@ public void ConstructorWithImperativeModelInitializesCollection() }; // Act - using var collection = new CosmosMongoCollection( + using var collection = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection", new() { Definition = definition }); @@ -91,7 +91,7 @@ public async Task CollectionExistsReturnsValidResultAsync(List collectio .Setup(l => l.ListCollectionNamesAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(mockCursor.Object); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, collectionName); @@ -141,7 +141,7 @@ public async Task EnsureCollectionExistsInvokesValidMethodsAsync() .Setup(l => l.Indexes) .Returns(mockMongoIndexManager.Object); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, CollectionName); @@ -165,7 +165,7 @@ public async Task DeleteInvokesValidMethodsAsync() // Arrange const string RecordKey = "key"; - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -189,7 +189,7 @@ public async Task DeleteBatchInvokesValidMethodsAsync() // Arrange List recordKeys = ["key1", "key2"]; - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -213,7 +213,7 @@ public async Task DeleteCollectionInvokesValidMethodsAsync() // Arrange const string CollectionName = "collection"; - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, CollectionName); @@ -250,7 +250,7 @@ public async Task GetReturnsValidRecordAsync() It.IsAny())) .ReturnsAsync(mockCursor.Object); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -288,7 +288,7 @@ public async Task GetBatchReturnsValidRecordAsync() It.IsAny())) .ReturnsAsync(mockCursor.Object); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -313,13 +313,13 @@ public async Task GetBatchReturnsValidRecordAsync() public async Task CanUpsertRecordAsync() { // Arrange - var hotel = new CosmosMongoHotelModel("key") { HotelName = "Test Name" }; + var hotel = new DocumentDBHotelModel("key") { HotelName = "Test Name" }; var serializerRegistry = BsonSerializer.SerializerRegistry; var documentSerializer = serializerRegistry.GetSerializer(); var expectedDefinition = Builders.Filter.Eq(document => document["_id"], "key"); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -341,11 +341,11 @@ public async Task CanUpsertRecordAsync() public async Task UpsertBatchReturnsRecordKeysAsync() { // Arrange - var hotel1 = new CosmosMongoHotelModel("key1") { HotelName = "Test Name 1" }; - var hotel2 = new CosmosMongoHotelModel("key2") { HotelName = "Test Name 2" }; - var hotel3 = new CosmosMongoHotelModel("key3") { HotelName = "Test Name 3" }; + var hotel1 = new DocumentDBHotelModel("key1") { HotelName = "Test Name 1" }; + var hotel2 = new DocumentDBHotelModel("key2") { HotelName = "Test Name 2" }; + var hotel3 = new DocumentDBHotelModel("key3") { HotelName = "Test Name 3" }; - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -420,7 +420,7 @@ public async Task SearchThrowsExceptionWithInvalidVectorTypeAsync(object vector, // Arrange this.MockCollectionForSearch(); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -478,7 +478,7 @@ public async Task SearchUsesValidQueryAsync( this.MockCollectionForSearch(); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -511,11 +511,11 @@ public async Task SearchThrowsExceptionWithNonExistentVectorPropertyNameAsync() // Arrange this.MockCollectionForSearch(); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); - var options = new MEVD.VectorSearchOptions { VectorProperty = r => "non-existent-property" }; + var options = new MEVD.VectorSearchOptions { VectorProperty = r => "non-existent-property" }; // Act & Assert await Assert.ThrowsAsync(async () => await sut.SearchAsync(new ReadOnlyMemory([1f, 2f, 3f]), top: 3, options).FirstOrDefaultAsync()); @@ -527,7 +527,7 @@ public async Task SearchReturnsRecordWithScoreAsync() // Arrange this.MockCollectionForSearch(); - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection"); @@ -610,11 +610,11 @@ private async Task TestUpsertWithModelAsync( var documentSerializer = serializerRegistry.GetSerializer(); var expectedDefinition = Builders.Filter.Eq(document => document["_id"], "key"); - CosmosMongoCollectionOptions? options = definition != null ? + DocumentDBCollectionOptions? options = definition != null ? new() { Definition = definition } : null; - using var sut = new CosmosMongoCollection( + using var sut = new DocumentDBCollection( this._mockMongoDatabase.Object, "collection", options); diff --git a/MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoHotelModel.cs b/MEVD/test/AzureDocumentDB.UnitTests/DocumentDBHotelModel.cs similarity index 94% rename from MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoHotelModel.cs rename to MEVD/test/AzureDocumentDB.UnitTests/DocumentDBHotelModel.cs index 60e18f4..84361e1 100644 --- a/MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoHotelModel.cs +++ b/MEVD/test/AzureDocumentDB.UnitTests/DocumentDBHotelModel.cs @@ -6,9 +6,9 @@ using Microsoft.Extensions.VectorData; using MongoDB.Bson.Serialization.Attributes; -namespace CosmosMongoDB.UnitTests; +namespace AzureDocumentDB.UnitTests; -public class CosmosMongoHotelModel(string hotelId) +public class DocumentDBHotelModel(string hotelId) { /// The key of the record. [VectorStoreKey] diff --git a/MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoVectorStoreTests.cs b/MEVD/test/AzureDocumentDB.UnitTests/DocumentDBVectorStoreTests.cs similarity index 74% rename from MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoVectorStoreTests.cs rename to MEVD/test/AzureDocumentDB.UnitTests/DocumentDBVectorStoreTests.cs index a6d8ce0..5d34d3a 100644 --- a/MEVD/test/CosmosMongoDB.UnitTests/CosmosMongoVectorStoreTests.cs +++ b/MEVD/test/AzureDocumentDB.UnitTests/DocumentDBVectorStoreTests.cs @@ -6,17 +6,17 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using CommunityToolkit.VectorData.CosmosMongoDB; +using CommunityToolkit.VectorData.AzureDocumentDB; using MongoDB.Driver; using Moq; using Xunit; -namespace CosmosMongoDB.UnitTests; +namespace AzureDocumentDB.UnitTests; /// -/// Unit tests for class. +/// Unit tests for class. /// -public sealed class CosmosMongoVectorStoreTests +public sealed class DocumentDBVectorStoreTests { private readonly Mock _mockMongoDatabase = new(); @@ -24,20 +24,20 @@ public sealed class CosmosMongoVectorStoreTests public void GetCollectionWithNotSupportedKeyThrowsException() { // Arrange - using var sut = new CosmosMongoVectorStore(this._mockMongoDatabase.Object); + using var sut = new DocumentDBVectorStore(this._mockMongoDatabase.Object); // Act & Assert - Assert.Throws(() => sut.GetCollection("collection")); + Assert.Throws(() => sut.GetCollection("collection")); } [Fact] public void GetCollectionWithoutFactoryReturnsDefaultCollection() { // Arrange - using var sut = new CosmosMongoVectorStore(this._mockMongoDatabase.Object); + using var sut = new DocumentDBVectorStore(this._mockMongoDatabase.Object); // Act - var collection = sut.GetCollection("collection"); + var collection = sut.GetCollection("collection"); // Assert Assert.NotNull(collection); @@ -63,7 +63,7 @@ public async Task ListCollectionNamesReturnsCollectionNamesAsync() .Setup(l => l.ListCollectionNamesAsync(It.IsAny(), It.IsAny())) .ReturnsAsync(mockCursor.Object); - using var sut = new CosmosMongoVectorStore(this._mockMongoDatabase.Object); + using var sut = new DocumentDBVectorStore(this._mockMongoDatabase.Object); // Act var actualCollectionNames = await sut.ListCollectionNamesAsync().ToListAsync(); diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoBasicModelTests.cs b/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoBasicModelTests.cs deleted file mode 100644 index 9ae768c..0000000 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoBasicModelTests.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosMongoDB.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosMongoDB.ConformanceTests.ModelTests; - -public class CosmosMongoBasicModelTests(CosmosMongoBasicModelTests.Fixture fixture) - : BasicModelTests(fixture), IClassFixture -{ - public new class Fixture : BasicModelTests.Fixture - { - public override TestStore TestStore => CosmosMongoTestStore.Instance; - } -} diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoMultiVectorModelTests.cs b/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoMultiVectorModelTests.cs deleted file mode 100644 index f133234..0000000 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoMultiVectorModelTests.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosMongoDB.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosMongoDB.ConformanceTests.ModelTests; - -public class CosmosMongoMultiVectorModelTests(CosmosMongoMultiVectorModelTests.Fixture fixture) - : MultiVectorModelTests(fixture), IClassFixture -{ - public new class Fixture : MultiVectorModelTests.Fixture - { - public override TestStore TestStore => CosmosMongoTestStore.Instance; - } -} diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoNoDataModelTests.cs b/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoNoDataModelTests.cs deleted file mode 100644 index f3923e5..0000000 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoNoDataModelTests.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosMongoDB.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosMongoDB.ConformanceTests.ModelTests; - -public class CosmosMongoNoDataModelTests(CosmosMongoNoDataModelTests.Fixture fixture) - : NoDataModelTests(fixture), IClassFixture -{ - public new class Fixture : NoDataModelTests.Fixture - { - public override TestStore TestStore => CosmosMongoTestStore.Instance; - } -} diff --git a/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoNoVectorModelTests.cs b/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoNoVectorModelTests.cs deleted file mode 100644 index edd73c8..0000000 --- a/MEVD/test/CosmosMongoDB.ConformanceTests/ModelTests/CosmosMongoNoVectorModelTests.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CosmosMongoDB.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosMongoDB.ConformanceTests.ModelTests; - -public class CosmosMongoNoVectorModelTests(CosmosMongoNoVectorModelTests.Fixture fixture) - : NoVectorModelTests(fixture), IClassFixture -{ - public new class Fixture : NoVectorModelTests.Fixture - { - public override TestStore TestStore => CosmosMongoTestStore.Instance; - } -} diff --git a/README.md b/README.md index 56b33d2..10c9f03 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The following NuGet packages have been published: | Package | Version | Downloads | |---------|---------|-----------| | [CommunityToolkit.VectorData.AzureAISearch] | ![AzureAISearch Version][v-azureaisearch] | ![AzureAISearch Downloads][d-azureaisearch] | -| [CommunityToolkit.VectorData.CosmosMongoDB] | ![CosmosMongoDB Version][v-cosmosmongodb] | ![CosmosMongoDB Downloads][d-cosmosmongodb] | +| [CommunityToolkit.VectorData.AzureDocumentDB] | ![AzureDocumentDB Version][v-azuredocumentdb] | ![AzureDocumentDB Downloads][d-azuredocumentdb] | | [CommunityToolkit.VectorData.CosmosNoSql] | ![CosmosNoSql Version][v-cosmosnosql] | ![CosmosNoSql Downloads][d-cosmosnosql] | | [CommunityToolkit.VectorData.InMemory] | ![InMemory Version][v-inmemory] | ![InMemory Downloads][d-inmemory] | | [CommunityToolkit.VectorData.PgVector] | ![PgVector Version][v-pgvector] | ![PgVector Downloads][d-pgvector] | @@ -29,7 +29,7 @@ The following NuGet packages have been published: The majority of tests in the test suite use [Testcontainers](https://testcontainers.com/) so that conformance tests are run against real servers running inside Docker containers. Docker must be running on your machine for this to work. -Some providers (AzureAISearch, CosmosMongoDB) require a cloud-hosted service and cannot be tested with containers. For those, first create the required cloud service, then configure the required settings (e.g., endpoint and API key) using environment variables or the `testsettings.development.json` file in the relevant test project directory. +Some providers (AzureAISearch, AzureDocumentDB) require a cloud-hosted service and cannot be tested with containers. For those, first create the required cloud service, then configure the required settings (e.g., endpoint and API key) using environment variables or the `testsettings.development.json` file in the relevant test project directory. > **NOTE**: The `testsettings.development.json` file contains secrets and is git-ignored. It should not be checked in. @@ -52,7 +52,7 @@ The Vector Data connectors in this toolkit were initially part of the [Semantic [CommunityToolkit.VectorData.AzureAISearch]: https://www.nuget.org/packages/CommunityToolkit.VectorData.AzureAISearch -[CommunityToolkit.VectorData.CosmosMongoDB]: https://www.nuget.org/packages/CommunityToolkit.VectorData.CosmosMongoDB +[CommunityToolkit.VectorData.AzureDocumentDB]: https://www.nuget.org/packages/CommunityToolkit.VectorData.AzureDocumentDB [CommunityToolkit.VectorData.CosmosNoSql]: https://www.nuget.org/packages/CommunityToolkit.VectorData.CosmosNoSql [CommunityToolkit.VectorData.InMemory]: https://www.nuget.org/packages/CommunityToolkit.VectorData.InMemory [CommunityToolkit.VectorData.PgVector]: https://www.nuget.org/packages/CommunityToolkit.VectorData.PgVector @@ -64,7 +64,7 @@ The Vector Data connectors in this toolkit were initially part of the [Semantic [v-azureaisearch]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.AzureAISearch -[v-cosmosmongodb]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.CosmosMongoDB +[v-azuredocumentdb]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.AzureDocumentDB [v-cosmosnosql]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.CosmosNoSql [v-inmemory]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.InMemory [v-pgvector]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.PgVector @@ -76,7 +76,7 @@ The Vector Data connectors in this toolkit were initially part of the [Semantic [d-azureaisearch]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.AzureAISearch -[d-cosmosmongodb]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.CosmosMongoDB +[d-azuredocumentdb]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.AzureDocumentDB [d-cosmosnosql]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.CosmosNoSql [d-inmemory]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.InMemory [d-pgvector]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.PgVector