diff --git a/CommunityToolkit.AI.slnx b/CommunityToolkit.AI.slnx index 31f6e90..acb7bee 100644 --- a/CommunityToolkit.AI.slnx +++ b/CommunityToolkit.AI.slnx @@ -9,7 +9,7 @@ - + @@ -23,8 +23,8 @@ - - + + diff --git a/MEVD/MEVD.slnf b/MEVD/MEVD.slnf index c8feb37..2b48cd6 100644 --- a/MEVD/MEVD.slnf +++ b/MEVD/MEVD.slnf @@ -4,7 +4,7 @@ "projects": [ "MEVD/src/AzureAISearch/AzureAISearch.csproj", - "MEVD/src/CosmosNoSql/CosmosNoSql.csproj", + "MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj", "MEVD/src/AzureDocumentDB/AzureDocumentDB.csproj", "MEVD/src/InMemory/InMemory.csproj", "MEVD/src/PgVector/PgVector.csproj", @@ -16,8 +16,8 @@ "MEVD/test/AzureAISearch.UnitTests/AzureAISearch.UnitTests.csproj", "MEVD/test/AzureAISearch.ConformanceTests/AzureAISearch.ConformanceTests.csproj", - "MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj", - "MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj", + "MEVD/test/AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj", + "MEVD/test/AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj", "MEVD/test/AzureDocumentDB.UnitTests/AzureDocumentDB.UnitTests.csproj", "MEVD/test/AzureDocumentDB.ConformanceTests/AzureDocumentDB.ConformanceTests.csproj", "MEVD/test/InMemory.UnitTests/InMemory.UnitTests.csproj", diff --git a/MEVD/src/CosmosNoSql/AssemblyInfo.cs b/MEVD/src/AzureCosmosDB/AssemblyInfo.cs similarity index 100% rename from MEVD/src/CosmosNoSql/AssemblyInfo.cs rename to MEVD/src/AzureCosmosDB/AssemblyInfo.cs diff --git a/MEVD/src/CosmosNoSql/CosmosNoSql.csproj b/MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj similarity index 81% rename from MEVD/src/CosmosNoSql/CosmosNoSql.csproj rename to MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj index 9c1c682..de2babe 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSql.csproj +++ b/MEVD/src/AzureCosmosDB/AzureCosmosDB.csproj @@ -1,12 +1,13 @@ 1.0.0 - CommunityToolkit.VectorData.CosmosNoSql + CommunityToolkit.VectorData.AzureCosmosDB $(AssemblyName) net10.0;net8.0;netstandard2.0;net462 Azure Cosmos DB for NoSQL provider for Microsoft.Extensions.VectorData Azure Cosmos DB for NoSQL provider for Microsoft.Extensions.VectorData by the .NET Community Toolkit + AzureCosmosDB;CosmosNoSql;VectorData true @@ -20,7 +21,7 @@ - + diff --git a/MEVD/src/CosmosNoSql/ByteArrayJsonConverter.cs b/MEVD/src/AzureCosmosDB/ByteArrayJsonConverter.cs similarity index 98% rename from MEVD/src/CosmosNoSql/ByteArrayJsonConverter.cs rename to MEVD/src/AzureCosmosDB/ByteArrayJsonConverter.cs index 15aba28..5df8413 100644 --- a/MEVD/src/CosmosNoSql/ByteArrayJsonConverter.cs +++ b/MEVD/src/AzureCosmosDB/ByteArrayJsonConverter.cs @@ -6,7 +6,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// /// A JSON converter for byte arrays that serializes them as JSON arrays of numbers diff --git a/MEVD/src/CosmosNoSql/ClientWrapper.cs b/MEVD/src/AzureCosmosDB/ClientWrapper.cs similarity index 94% rename from MEVD/src/CosmosNoSql/ClientWrapper.cs rename to MEVD/src/AzureCosmosDB/ClientWrapper.cs index 53eec7a..cbaa5ab 100644 --- a/MEVD/src/CosmosNoSql/ClientWrapper.cs +++ b/MEVD/src/AzureCosmosDB/ClientWrapper.cs @@ -5,7 +5,7 @@ using System.Threading; using Microsoft.Azure.Cosmos; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; internal sealed class ClientWrapper : IDisposable { diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlCollection.cs b/MEVD/src/AzureCosmosDB/CosmosCollection.cs similarity index 90% rename from MEVD/src/CosmosNoSql/CosmosNoSqlCollection.cs rename to MEVD/src/AzureCosmosDB/CosmosCollection.cs index 8cd8988..37dfceb 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlCollection.cs +++ b/MEVD/src/AzureCosmosDB/CosmosCollection.cs @@ -25,17 +25,17 @@ using SKDistanceFunction = Microsoft.Extensions.VectorData.DistanceFunction; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Service for storing and retrieving vector records, that uses Azure CosmosDB NoSQL as the underlying storage. +/// Service for storing and retrieving vector records, that uses Azure Cosmos NoSQL as the underlying storage. /// /// /// The data type of the record key. Supported types are and (in which case the partition key -/// is the document ID), and (for other partition key configurations). +/// is the document ID), and (for other partition key configurations). /// 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 CosmosNoSqlCollection : VectorStoreCollection, IKeywordHybridSearchable +public class CosmosCollection : VectorStoreCollection, IKeywordHybridSearchable where TKey : notnull where TRecord : class #pragma warning restore CA1711 // Identifiers should not have incorrect suffix @@ -51,7 +51,7 @@ public class CosmosNoSqlCollection : VectorStoreCollection that can be used to manage the collections in Azure CosmosDB NoSQL. + /// that can be used to manage the collections in Azure Cosmos NoSQL. private readonly Database _database; /// The model for this collection. @@ -61,8 +61,8 @@ public class CosmosNoSqlCollection : VectorStoreCollectionThe properties to use as partition key (supports hierarchical partition keys up to 3 levels). private readonly List _partitionKeyProperties; - /// The mapper to use when mapping between the consumer data model and the Azure CosmosDB NoSQL record. - private readonly ICosmosNoSqlMapper _mapper; + /// The mapper to use when mapping between the consumer data model and the Azure Cosmos NoSQL record. + private readonly ICosmosMapper _mapper; /// public override string Name { get; } @@ -74,14 +74,14 @@ public class CosmosNoSqlCollection : 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 NoSQL. - /// The name of the collection that this will access. + /// that can be used to manage the collections in Azure Cosmos NoSQL. + /// The name of the collection that this will access. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlCollection(Database database, string name, CosmosNoSqlCollectionOptions? options = default) + public CosmosCollection(Database database, string name, CosmosCollectionOptions? options = default) : this(new(database.Client, ownsClient: false), _ => database, name, options) { Throw.IfNull(database); @@ -89,21 +89,21 @@ public CosmosNoSqlCollection(Database database, string name, CosmosNoSqlCollecti } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Connection string required to connect to Azure CosmosDB NoSQL. - /// Database name for Azure CosmosDB NoSQL. - /// The name of the collection that this will access. + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. + /// The name of the collection that this will access. /// Optional configuration options for . /// Optional configuration options for . [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlCollection( + public CosmosCollection( string connectionString, string databaseName, string name, CosmosClientOptions? clientOptions = null, - CosmosNoSqlCollectionOptions? options = null) + CosmosCollectionOptions? options = null) : this( new ClientWrapper(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), @@ -115,34 +115,34 @@ public CosmosNoSqlCollection( Throw.IfNullOrWhitespace(name); } - internal CosmosNoSqlCollection( + internal CosmosCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - CosmosNoSqlCollectionOptions? options) + CosmosCollectionOptions? options) : this( clientWrapper, databaseProvider, name, static options => typeof(TRecord) == typeof(Dictionary) - ? throw new NotSupportedException(VectorDataStrings.NonDynamicCollectionWithDictionaryNotSupported(typeof(CosmosNoSqlDynamicCollection))) - : new CosmosNoSqlModelBuilder() + ? throw new NotSupportedException(VectorDataStrings.NonDynamicCollectionWithDictionaryNotSupported(typeof(CosmosDynamicCollection))) + : new CosmosModelBuilder() .Build(typeof(TRecord), typeof(TKey), options.Definition, options.EmbeddingGenerator, options.JsonSerializerOptions ?? JsonSerializerOptions.Default), options) { } - internal CosmosNoSqlCollection( + internal CosmosCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - Func modelFactory, - CosmosNoSqlCollectionOptions? options) + Func modelFactory, + CosmosCollectionOptions? options) { - // Validate TKey: must be string or Guid (partition key = document ID), CosmosNoSqlKey (other partition key cases), or object (used by CosmosNoSqlDynamicCollection). - if (typeof(TKey) != typeof(string) && typeof(TKey) != typeof(Guid) && typeof(TKey) != typeof(CosmosNoSqlKey) && typeof(TKey) != typeof(object)) + // Validate TKey: must be string or Guid (partition key = document ID), CosmosKey (other partition key cases), or object (used by CosmosDynamicCollection). + if (typeof(TKey) != typeof(string) && typeof(TKey) != typeof(Guid) && typeof(TKey) != typeof(CosmosKey) && typeof(TKey) != typeof(object)) { - throw new NotSupportedException($"The key type must be string, Guid, or CosmosNoSqlKey. Received: {typeof(TKey).Name}"); + throw new NotSupportedException($"The key type must be string, Guid, or CosmosKey. Received: {typeof(TKey).Name}"); } try @@ -156,7 +156,7 @@ internal CosmosNoSqlCollection( $"is required to be configured for {this.GetType().Name}."); } - options ??= CosmosNoSqlCollectionOptions.Default; + options ??= CosmosCollectionOptions.Default; // Assign. this.Name = name; @@ -167,8 +167,8 @@ internal CosmosNoSqlCollection( // Assign mapper. this._mapper = typeof(TRecord) == typeof(Dictionary) - ? (new CosmosNoSqlDynamicMapper(this._model, jsonSerializerOptions) as ICosmosNoSqlMapper)! - : new CosmosNoSqlMapper(this._model, options.JsonSerializerOptions); + ? (new CosmosDynamicMapper(this._model, jsonSerializerOptions) as ICosmosMapper)! + : new CosmosMapper(this._model, options.JsonSerializerOptions); // Setup partition key properties (supports hierarchical partition keys up to 3 levels) if (options.PartitionKeyProperties is null) @@ -205,18 +205,18 @@ internal CosmosNoSqlCollection( // When using simple key types (string/Guid), the partition key must be the key property only, // since the partition key value cannot be independently specified via a simple key. // Users who need hierarchical partition keys, a non-key partition key, or no partition key at all - // must use CosmosNoSqlKey as the key type. + // must use CosmosKey as the key type. if ((typeof(TKey) == typeof(string) || typeof(TKey) == typeof(Guid)) && (this._partitionKeyProperties is not [var singlePkProperty] || singlePkProperty != this._model.KeyProperty)) { throw new ArgumentException( $"When using {typeof(TKey).Name} as the key type, the partition key must be the key property " + - $"('{this._model.KeyProperty.ModelName}'). To use a different partition key configuration, use CosmosNoSqlKey as the key type."); + $"('{this._model.KeyProperty.ModelName}'). To use a different partition key configuration, use CosmosKey as the key type."); } this._collectionMetadata = new() { - VectorStoreSystemName = CosmosNoSqlConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosConstants.VectorStoreSystemName, VectorStoreName = this._database.Id, CollectionName = name }; @@ -291,7 +291,7 @@ public override async Task EnsureCollectionExistsAsync(CancellationToken cancell { throw new VectorStoreException("Call to vector store failed.", ex) { - VectorStoreSystemName = CosmosNoSqlConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosConstants.VectorStoreSystemName, VectorStoreName = this._collectionMetadata.VectorStoreName, CollectionName = this.Name, OperationName = "CreateContainer" @@ -316,7 +316,7 @@ await this._database { throw new VectorStoreException("Call to vector store failed.", ex) { - VectorStoreSystemName = CosmosNoSqlConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosConstants.VectorStoreSystemName, VectorStoreName = this._collectionMetadata.VectorStoreName, CollectionName = this.Name, OperationName = "DeleteContainer" @@ -493,7 +493,7 @@ await this.RunOperationAsync(OperationName, () => { var vectorProperty = model.VectorProperties[i]; - if (CosmosNoSqlModelBuilder.IsVectorPropertyTypeValidCore(vectorProperty.Type, out _)) + if (CosmosModelBuilder.IsVectorPropertyTypeValidCore(vectorProperty.Type, out _)) { continue; } @@ -548,7 +548,7 @@ public override async IAsyncEnumerable> SearchAsync< var vectorProperty = this._model.GetVectorPropertyOrSingle(options); object vector = await GetSearchVectorAsync(searchValue, vectorProperty, cancellationToken).ConfigureAwait(false); - var queryDefinition = CosmosNoSqlCollectionQueryBuilder.BuildSearchQuery( + var queryDefinition = CosmosCollectionQueryBuilder.BuildSearchQuery( vector, null, this._model, @@ -593,7 +593,7 @@ _ when vectorProperty.EmbeddingGenerationDispatcher is not null => await vectorProperty.GenerateEmbeddingAsync(searchValue, cancellationToken).ConfigureAwait(false), _ => vectorProperty.EmbeddingGenerator is null - ? throw new NotSupportedException(VectorDataStrings.InvalidSearchInputAndNoEmbeddingGeneratorWasConfigured(searchValue.GetType(), CosmosNoSqlModelBuilder.SupportedVectorTypes)) + ? throw new NotSupportedException(VectorDataStrings.InvalidSearchInputAndNoEmbeddingGeneratorWasConfigured(searchValue.GetType(), CosmosModelBuilder.SupportedVectorTypes)) : throw new InvalidOperationException(VectorDataStrings.IncompatibleEmbeddingGeneratorWasConfiguredForInputType(typeof(TInput), vectorProperty.EmbeddingGenerator.GetType())) }; @@ -610,9 +610,9 @@ public override async IAsyncEnumerable GetAsync(Expression> HybridSearchAsync( + var queryDefinition = CosmosCollectionQueryBuilder.BuildSearchQuery( vector, keywords, this._model, @@ -692,10 +692,10 @@ private void VerifyVectorType(TVector? vector) var vectorType = vector!.GetType(); - if (!CosmosNoSqlModelBuilder.IsVectorPropertyTypeValidCore(vectorType, out var supportedTypes)) + if (!CosmosModelBuilder.IsVectorPropertyTypeValidCore(vectorType, out var supportedTypes)) { throw new NotSupportedException( - $"The provided vector type {vectorType.FullName} is not supported by the Azure CosmosDB NoSQL connector. Supported types are: {supportedTypes}"); + $"The provided vector type {vectorType.FullName} is not supported by the Azure Cosmos NoSQL connector. Supported types are: {supportedTypes}"); } } @@ -711,11 +711,11 @@ private Task RunOperationAsync(string operationName, Func> operati private (string DocumentId, PartitionKey PartitionKey) GetDocumentIdAndPartitionKey(TKey key) => key switch { - CosmosNoSqlKey cosmosKey => (cosmosKey.DocumentId, cosmosKey.PartitionKey), + CosmosKey cosmosKey => (cosmosKey.DocumentId, cosmosKey.PartitionKey), string s => (s, new PartitionKey(s)), Guid g => (g.ToString(), new PartitionKey(g.ToString())), _ => throw new InvalidOperationException( - $"Keys must be of type string, Guid, or CosmosNoSqlKey. Received key of type '{key.GetType().FullName}'.") + $"Keys must be of type string, Guid, or CosmosKey. Received key of type '{key.GetType().FullName}'.") }; /// @@ -806,7 +806,7 @@ private ContainerProperties GetContainerProperties() } /// - /// More information about Azure CosmosDB NoSQL index kinds here: . + /// More information about Azure Cosmos NoSQL index kinds here: . /// private static VectorIndexType GetIndexKind(string? indexKind, string vectorPropertyName) => indexKind switch @@ -814,11 +814,11 @@ private static VectorIndexType GetIndexKind(string? indexKind, string vectorProp "DiskAnn" or null => VectorIndexType.DiskANN, "Flat" => VectorIndexType.Flat, "QuantizedFlat" => VectorIndexType.QuantizedFlat, - _ => throw new InvalidOperationException($"Index kind '{indexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB NoSQL VectorStore.") + _ => throw new InvalidOperationException($"Index kind '{indexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure Cosmos NoSQL VectorStore.") }; /// - /// More information about Azure CosmosDB NoSQL distance functions here: . + /// More information about Azure Cosmos NoSQL distance functions here: . /// private static DistanceFunction GetDistanceFunction(string? distanceFunction, string vectorPropertyName) => distanceFunction switch @@ -827,7 +827,7 @@ private static DistanceFunction GetDistanceFunction(string? distanceFunction, st SKDistanceFunction.DotProductSimilarity => DistanceFunction.DotProduct, SKDistanceFunction.EuclideanDistance => DistanceFunction.Euclidean, - _ => throw new NotSupportedException($"Distance function '{distanceFunction}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB NoSQL VectorStore.") + _ => throw new NotSupportedException($"Distance function '{distanceFunction}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure Cosmos NoSQL VectorStore.") }; /// @@ -845,7 +845,7 @@ private static VectorDataType GetDataType(Type vectorDataType, string vectorProp Type type when type == typeof(ReadOnlyMemory) || type == typeof(Embedding) || type == typeof(sbyte[]) => VectorDataType.Int8, - _ => throw new InvalidOperationException($"Data type '{vectorDataType}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB NoSQL VectorStore.") + _ => throw new InvalidOperationException($"Data type '{vectorDataType}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure Cosmos NoSQL VectorStore.") }; private async IAsyncEnumerable GetItemsAsync(QueryDefinition queryDefinition, string operationName, [EnumeratorCancellation] CancellationToken cancellationToken) diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlCollectionOptions.cs b/MEVD/src/AzureCosmosDB/CosmosCollectionOptions.cs similarity index 79% rename from MEVD/src/CosmosNoSql/CosmosNoSqlCollectionOptions.cs rename to MEVD/src/AzureCosmosDB/CosmosCollectionOptions.cs index b26e936..65fa914 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlCollectionOptions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosCollectionOptions.cs @@ -6,23 +6,23 @@ using Microsoft.Azure.Cosmos; using Microsoft.Extensions.VectorData; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Options when creating a . +/// Options when creating a . /// -public sealed class CosmosNoSqlCollectionOptions : VectorStoreCollectionOptions +public sealed class CosmosCollectionOptions : VectorStoreCollectionOptions { - internal static readonly CosmosNoSqlCollectionOptions Default = new(); + internal static readonly CosmosCollectionOptions Default = new(); /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CosmosNoSqlCollectionOptions() + public CosmosCollectionOptions() { } - internal CosmosNoSqlCollectionOptions(CosmosNoSqlCollectionOptions? source) : base(source) + internal CosmosCollectionOptions(CosmosCollectionOptions? source) : base(source) { this.JsonSerializerOptions = source?.JsonSerializerOptions; this.PartitionKeyProperties = source?.PartitionKeyProperties is null ? null : [.. source.PartitionKeyProperties]; @@ -31,7 +31,7 @@ internal CosmosNoSqlCollectionOptions(CosmosNoSqlCollectionOptions? source) : ba } /// - /// Gets or sets the JSON serializer options to use when converting between the data model and the Azure CosmosDB NoSQL record. + /// Gets or sets the JSON serializer options to use when converting between the data model and the Azure Cosmos NoSQL record. /// public JsonSerializerOptions? JsonSerializerOptions { get; set; } @@ -47,7 +47,7 @@ internal CosmosNoSqlCollectionOptions(CosmosNoSqlCollectionOptions? source) : ba /// When (the default), the key property (document ID) is automatically used as the partition key - a common /// Cosmos DB strategy; in this mode, the collection key type must be or . /// To use a different partition key (or hierarchical partition keys), specify the key properties here and use - /// as the key type. + /// as the key type. /// /// public IReadOnlyList? PartitionKeyProperties { get; set; } diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs b/MEVD/src/AzureCosmosDB/CosmosCollectionQueryBuilder.cs similarity index 96% rename from MEVD/src/CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs rename to MEVD/src/AzureCosmosDB/CosmosCollectionQueryBuilder.cs index ccdceae..6afe13a 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlCollectionQueryBuilder.cs +++ b/MEVD/src/AzureCosmosDB/CosmosCollectionQueryBuilder.cs @@ -12,15 +12,15 @@ using Microsoft.Extensions.VectorData.ProviderServices; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Contains helpers to build queries for Azure CosmosDB NoSQL. +/// Contains helpers to build queries for Azure Cosmos NoSQL. /// -internal static class CosmosNoSqlCollectionQueryBuilder +internal static class CosmosCollectionQueryBuilder { /// - /// Builds to get items from Azure CosmosDB NoSQL using vector search. + /// Builds to get items from Azure Cosmos NoSQL using vector search. /// public static QueryDefinition BuildSearchQuery( object vector, @@ -41,7 +41,7 @@ public static QueryDefinition BuildSearchQuery( const string VectorVariableName = "@vector"; const string KeywordVariablePrefix = "@keyword"; - var tableVariableName = CosmosNoSqlConstants.ContainerAlias; + var tableVariableName = CosmosConstants.ContainerAlias; IEnumerable projectionProperties = model.Properties; if (!includeVectors) @@ -56,7 +56,7 @@ public static QueryDefinition BuildSearchQuery( // Build filter object. var (filterClause, filterParameters) = filter is not null - ? new CosmosNoSqlFilterTranslator().Translate(filter, model) + ? new CosmosFilterTranslator().Translate(filter, model) : ((string?)null, new Dictionary()); var queryParameters = new Dictionary @@ -162,7 +162,7 @@ internal static QueryDefinition BuildSearchQuery( FilteredRecordRetrievalOptions filterOptions, int top) { - var tableVariableName = CosmosNoSqlConstants.ContainerAlias; + var tableVariableName = CosmosConstants.ContainerAlias; IEnumerable projectionProperties = model.Properties; if (!filterOptions.IncludeVectors) diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlConstants.cs b/MEVD/src/AzureCosmosDB/CosmosConstants.cs similarity index 67% rename from MEVD/src/CosmosNoSql/CosmosNoSqlConstants.cs rename to MEVD/src/AzureCosmosDB/CosmosConstants.cs index 9b35882..17f2dd0 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlConstants.cs +++ b/MEVD/src/AzureCosmosDB/CosmosConstants.cs @@ -1,19 +1,19 @@ // 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.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal static class CosmosNoSqlConstants +internal static class CosmosConstants { internal const string VectorStoreSystemName = "azure.cosmosdbnosql"; /// - /// Reserved key property name in Azure CosmosDB NoSQL. + /// Reserved key property name in Azure Cosmos NoSQL. /// internal const string ReservedKeyPropertyName = "id"; /// - /// Variable name for table in Azure CosmosDB NoSQL queries. + /// Variable name for table in Azure Cosmos NoSQL queries. /// Can be any string. Example: "SELECT x.Name FROM x". /// internal const char ContainerAlias = 'x'; diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlDynamicCollection.cs b/MEVD/src/AzureCosmosDB/CosmosDynamicCollection.cs similarity index 73% rename from MEVD/src/CosmosNoSql/CosmosNoSqlDynamicCollection.cs rename to MEVD/src/AzureCosmosDB/CosmosDynamicCollection.cs index f53f9bc..7a3471e 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlDynamicCollection.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDynamicCollection.cs @@ -8,30 +8,30 @@ using Microsoft.Azure.Cosmos; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Represents a collection of vector store records in a CosmosNoSql database, mapped to a dynamic Dictionary<string, object?>. +/// Represents a collection of vector store records in a Cosmos database, mapped to a dynamic Dictionary<string, object?>. /// /// /// -/// This collection accepts keys of type , but only instances +/// This collection accepts keys of type , but only instances /// are supported at runtime. Passing any other key type will result in an . /// /// #pragma warning disable CA1711 // Identifiers should not have incorrect suffix -public sealed class CosmosNoSqlDynamicCollection : CosmosNoSqlCollection> +public sealed class CosmosDynamicCollection : CosmosCollection> #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 Azure CosmosDB NoSQL. + /// that can be used to manage the collections in Azure Cosmos NoSQL. /// The name of the collection. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlDynamicCollection(Database database, string name, CosmosNoSqlCollectionOptions options) + public CosmosDynamicCollection(Database database, string name, CosmosCollectionOptions options) : this( new(database.Client, ownsClient: false), _ => database, @@ -41,21 +41,21 @@ public CosmosNoSqlDynamicCollection(Database database, string name, CosmosNoSqlC } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Connection string required to connect to Azure CosmosDB NoSQL. - /// Database name for Azure CosmosDB NoSQL. - /// The name of the collection that this will access. + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. + /// The name of the collection that this will access. /// Optional configuration options for . /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlDynamicCollection( + public CosmosDynamicCollection( string connectionString, string databaseName, string collectionName, CosmosClientOptions? clientOptions = null, - CosmosNoSqlCollectionOptions? options = null) + CosmosCollectionOptions? options = null) : this( new(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), @@ -67,16 +67,16 @@ public CosmosNoSqlDynamicCollection( Throw.IfNullOrWhitespace(collectionName); } - internal CosmosNoSqlDynamicCollection( + internal CosmosDynamicCollection( ClientWrapper clientWrapper, Func databaseProvider, string name, - CosmosNoSqlCollectionOptions? options) + CosmosCollectionOptions? options) : base( clientWrapper, databaseProvider, name, - static options => new CosmosNoSqlModelBuilder() + static options => new CosmosModelBuilder() .BuildDynamic( options.Definition ?? throw new ArgumentException("Definition is required for dynamic collections"), options.EmbeddingGenerator, diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlDynamicMapper.cs b/MEVD/src/AzureCosmosDB/CosmosDynamicMapper.cs similarity index 94% rename from MEVD/src/CosmosNoSql/CosmosNoSqlDynamicMapper.cs rename to MEVD/src/AzureCosmosDB/CosmosDynamicMapper.cs index d90c1e7..7550cff 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlDynamicMapper.cs +++ b/MEVD/src/AzureCosmosDB/CosmosDynamicMapper.cs @@ -12,13 +12,13 @@ using MEAI = Microsoft.Extensions.AI; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// A mapper that maps between the generic Semantic Kernel data model and the model that the data is stored under, within Azure CosmosDB NoSQL. +/// A mapper that maps between the generic Semantic Kernel data model and the model that the data is stored under, within Azure Cosmos NoSQL. /// -internal sealed class CosmosNoSqlDynamicMapper(CollectionModel model, JsonSerializerOptions jsonSerializerOptions) - : ICosmosNoSqlMapper> +internal sealed class CosmosDynamicMapper(CollectionModel model, JsonSerializerOptions jsonSerializerOptions) + : ICosmosMapper> { public JsonObject MapFromDataToStorageModel(Dictionary dataModel, int recordIndex, IReadOnlyList?[]? generatedEmbeddings) { @@ -26,7 +26,7 @@ public JsonObject MapFromDataToStorageModel(Dictionary dataMode var jsonObject = new JsonObject { - [CosmosNoSqlConstants.ReservedKeyPropertyName] = !dataModel.TryGetValue(model.KeyProperty.ModelName, out var keyValue) + [CosmosConstants.ReservedKeyPropertyName] = !dataModel.TryGetValue(model.KeyProperty.ModelName, out var keyValue) ? throw new InvalidOperationException($"Missing value for key property '{model.KeyProperty.ModelName}") : keyValue switch { @@ -124,7 +124,7 @@ static bool TryGetReadOnlyMemory(object value, [NotNullWhen(true)] out ReadOn switch (property) { case KeyPropertyModel keyProperty: - var key = (string?)storageModel[CosmosNoSqlConstants.ReservedKeyPropertyName] + var key = (string?)storageModel[CosmosConstants.ReservedKeyPropertyName] ?? throw new InvalidOperationException($"The key property '{keyProperty.StorageName}' is missing from the record retrieved from storage."); result[keyProperty.ModelName] = keyProperty.Type switch diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlFilterTranslator.cs b/MEVD/src/AzureCosmosDB/CosmosFilterTranslator.cs similarity index 98% rename from MEVD/src/CosmosNoSql/CosmosNoSqlFilterTranslator.cs rename to MEVD/src/AzureCosmosDB/CosmosFilterTranslator.cs index 7bed782..2367cd5 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlFilterTranslator.cs +++ b/MEVD/src/AzureCosmosDB/CosmosFilterTranslator.cs @@ -11,11 +11,11 @@ using Microsoft.Extensions.VectorData.ProviderServices; using Microsoft.Extensions.VectorData.ProviderServices.Filter; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; #pragma warning disable MEVD9001 // Experimental: filter translation base types -internal class CosmosNoSqlFilterTranslator : FilterTranslatorBase +internal class CosmosFilterTranslator : FilterTranslatorBase { private readonly Dictionary _parameters = []; private readonly StringBuilder _sql = new(); @@ -364,7 +364,7 @@ protected void TranslateQueryParameter(string name, object? value) protected virtual void GeneratePropertyAccess(PropertyModel property) => this._sql - .Append(CosmosNoSqlConstants.ContainerAlias) + .Append(CosmosConstants.ContainerAlias) .Append("[\"") .Append(property.StorageName.Replace(@"\", @"\\").Replace("\"", "\\\"")) .Append("\"]"); diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlKey.cs b/MEVD/src/AzureCosmosDB/CosmosKey.cs similarity index 69% rename from MEVD/src/CosmosNoSql/CosmosNoSqlKey.cs rename to MEVD/src/AzureCosmosDB/CosmosKey.cs index 90709bc..151e880 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlKey.cs +++ b/MEVD/src/AzureCosmosDB/CosmosKey.cs @@ -4,10 +4,10 @@ using System; using Microsoft.Azure.Cosmos; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Represents a key for Azure CosmosDB NoSQL, containing both the record key (document ID) and the partition key. +/// Represents a key for Azure Cosmos NoSQL, containing both the record key (document ID) and the partition key. /// /// /// @@ -21,98 +21,98 @@ namespace CommunityToolkit.VectorData.CosmosNoSql; /// /// // This is conceptually a record, but we're targeting .NET Standard 2.0 too. -public readonly struct CosmosNoSqlKey : IEquatable +public readonly struct CosmosKey : IEquatable { /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(string documentId, string partitionKey) + public CosmosKey(string documentId, string partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(Guid documentId, string partitionKey) + public CosmosKey(Guid documentId, string partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(string documentId, Guid partitionKey) + public CosmosKey(string documentId, Guid partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey.ToString()); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(Guid documentId, Guid partitionKey) + public CosmosKey(Guid documentId, Guid partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey.ToString()); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(string documentId, bool partitionKey) + public CosmosKey(string documentId, bool partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(Guid documentId, bool partitionKey) + public CosmosKey(Guid documentId, bool partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(string documentId, double partitionKey) + public CosmosKey(string documentId, double partitionKey) { this.DocumentId = documentId; this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. - public CosmosNoSqlKey(Guid documentId, double partitionKey) + public CosmosKey(Guid documentId, double partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = new PartitionKey(partitionKey); } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. @@ -120,14 +120,14 @@ public CosmosNoSqlKey(Guid documentId, double partitionKey) /// Use this constructor for hierarchical partition keys or special partition key values like or . /// For hierarchical partition keys, construct the using . /// - public CosmosNoSqlKey(string documentId, PartitionKey partitionKey) + public CosmosKey(string documentId, PartitionKey partitionKey) { this.DocumentId = documentId; this.PartitionKey = partitionKey; } /// - /// Initializes a new instance of the struct with a document ID and partition key. + /// Initializes a new instance of the struct with a document ID and partition key. /// /// The document ID. /// The Cosmos DB partition key. @@ -135,7 +135,7 @@ public CosmosNoSqlKey(string documentId, PartitionKey partitionKey) /// Use this constructor for hierarchical partition keys or special partition key values like or . /// For hierarchical partition keys, construct the using . /// - public CosmosNoSqlKey(Guid documentId, PartitionKey partitionKey) + public CosmosKey(Guid documentId, PartitionKey partitionKey) { this.DocumentId = documentId.ToString(); this.PartitionKey = partitionKey; @@ -159,26 +159,26 @@ public CosmosNoSqlKey(Guid documentId, PartitionKey partitionKey) public PartitionKey PartitionKey { get; } /// - public bool Equals(CosmosNoSqlKey other) + public bool Equals(CosmosKey other) => Equals(this.DocumentId, other.DocumentId) && this.PartitionKey.Equals(other.PartitionKey); /// public override bool Equals(object? obj) - => obj is CosmosNoSqlKey other && this.Equals(other); + => obj is CosmosKey other && this.Equals(other); /// public override int GetHashCode() => HashCode.Combine(this.DocumentId, this.PartitionKey); /// - /// Determines whether two instances are equal. + /// Determines whether two instances are equal. /// - public static bool operator ==(CosmosNoSqlKey left, CosmosNoSqlKey right) + public static bool operator ==(CosmosKey left, CosmosKey right) => left.Equals(right); /// - /// Determines whether two instances are not equal. + /// Determines whether two instances are not equal. /// - public static bool operator !=(CosmosNoSqlKey left, CosmosNoSqlKey right) + public static bool operator !=(CosmosKey left, CosmosKey right) => !left.Equals(right); } diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlMapper.cs b/MEVD/src/AzureCosmosDB/CosmosMapper.cs similarity index 92% rename from MEVD/src/CosmosNoSql/CosmosNoSqlMapper.cs rename to MEVD/src/AzureCosmosDB/CosmosMapper.cs index 7b97536..d21c84d 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlMapper.cs +++ b/MEVD/src/AzureCosmosDB/CosmosMapper.cs @@ -10,20 +10,20 @@ using Microsoft.Extensions.VectorData.ProviderServices; using MEAI = Microsoft.Extensions.AI; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Class for mapping between a json node stored in Azure CosmosDB NoSQL and the consumer data model. +/// Class for mapping between a json node stored in Azure Cosmos NoSQL and the consumer data model. /// /// The consumer data model to map to or from. -internal sealed class CosmosNoSqlMapper : ICosmosNoSqlMapper +internal sealed class CosmosMapper : ICosmosMapper where TRecord : class { private readonly CollectionModel _model; private readonly KeyPropertyModel _keyProperty; private readonly JsonSerializerOptions _jsonSerializerOptions; - public CosmosNoSqlMapper(CollectionModel model, JsonSerializerOptions? jsonSerializerOptions) + public CosmosMapper(CollectionModel model, JsonSerializerOptions? jsonSerializerOptions) { this._model = model; this._keyProperty = model.KeyProperty; @@ -40,10 +40,10 @@ public JsonObject MapFromDataToStorageModel(TRecord dataModel, int recordIndex, { var jsonObject = JsonSerializer.SerializeToNode(dataModel, this._jsonSerializerOptions)!.AsObject(); - // The key property in Azure CosmosDB NoSQL is always named 'id'. + // The key property in Azure Cosmos NoSQL is always named 'id'. // But the external JSON serializer used just above isn't aware of that, and will produce a JSON object with another name, taking into // account e.g. naming policies. SerializedKeyName gets populated in the model builder - containing that name - once VectorStoreModelBuildingOptions.ReservedKeyPropertyName is set - RenameJsonProperty(jsonObject, this._keyProperty.SerializedKeyName!, CosmosNoSqlConstants.ReservedKeyPropertyName); + RenameJsonProperty(jsonObject, this._keyProperty.SerializedKeyName!, CosmosConstants.ReservedKeyPropertyName); // Go over the vector properties; inject any generated embeddings to overwrite the JSON serialized above. // Also, for Embedding properties we also need to overwrite with a simple array (since Embedding gets serialized as a complex object). @@ -117,7 +117,7 @@ public JsonObject MapFromDataToStorageModel(TRecord dataModel, int recordIndex, public TRecord MapFromStorageToDataModel(JsonObject storageModel, bool includeVectors) { // See above comment. - RenameJsonProperty(storageModel, CosmosNoSqlConstants.ReservedKeyPropertyName, this._keyProperty.SerializedKeyName!); + RenameJsonProperty(storageModel, CosmosConstants.ReservedKeyPropertyName, this._keyProperty.SerializedKeyName!); foreach (var vectorProperty in this._model.VectorProperties) { diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlModelBuilder.cs b/MEVD/src/AzureCosmosDB/CosmosModelBuilder.cs similarity index 88% rename from MEVD/src/CosmosNoSql/CosmosNoSqlModelBuilder.cs rename to MEVD/src/AzureCosmosDB/CosmosModelBuilder.cs index 9184a92..254898e 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlModelBuilder.cs +++ b/MEVD/src/AzureCosmosDB/CosmosModelBuilder.cs @@ -7,9 +7,9 @@ using Microsoft.Extensions.AI; using Microsoft.Extensions.VectorData.ProviderServices; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal class CosmosNoSqlModelBuilder() : CollectionJsonModelBuilder(s_modelBuildingOptions) +internal class CosmosModelBuilder() : CollectionJsonModelBuilder(s_modelBuildingOptions) { internal const string SupportedVectorTypes = "ReadOnlyMemory, Embedding, float[], ReadOnlyMemory, Embedding, byte[], ReadOnlyMemory, Embedding, sbyte[]"; @@ -18,19 +18,19 @@ internal class CosmosNoSqlModelBuilder() : CollectionJsonModelBuilder(s_modelBui RequiresAtLeastOneVector = false, SupportsMultipleVectors = true, UsesExternalSerializer = true, - ReservedKeyStorageName = CosmosNoSqlConstants.ReservedKeyPropertyName + ReservedKeyStorageName = CosmosConstants.ReservedKeyPropertyName }; protected override void ValidateKeyProperty(KeyPropertyModel keyProperty) { - // CosmosNoSqlKey is a composite key type (document ID + partition key) that doesn't correspond to any single key property type; + // CosmosKey is a composite key type (document ID + partition key) that doesn't correspond to any single key property type; // skip the base TKey-to-key-property validation when it's used. - if (this.KeyType != typeof(CosmosNoSqlKey)) + if (this.KeyType != typeof(CosmosKey)) { base.ValidateKeyProperty(keyProperty); } - // Note that the key property in Cosmos NoSQL refers to the document ID, not to the CosmosNoSqlKey structure which includes both + // Note that the key property in Cosmos NoSQL refers to the document ID, not to the CosmosKey structure which includes both // the document ID and the partition key (and which is the generic TKey type parameter of the collection). var type = keyProperty.Type; diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlServiceCollectionExtensions.cs b/MEVD/src/AzureCosmosDB/CosmosServiceCollectionExtensions.cs similarity index 66% rename from MEVD/src/CosmosNoSql/CosmosNoSqlServiceCollectionExtensions.cs rename to MEVD/src/AzureCosmosDB/CosmosServiceCollectionExtensions.cs index 0c6b045..1ba4980 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlServiceCollectionExtensions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosServiceCollectionExtensions.cs @@ -7,7 +7,7 @@ using Microsoft.Azure.Cosmos; using Microsoft.Extensions.AI; using Microsoft.Extensions.VectorData; -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Shared.Diagnostics; #pragma warning disable IDE0130 // Namespace does not match folder structure @@ -15,148 +15,148 @@ namespace Microsoft.Extensions.DependencyInjection; #pragma warning restore IDE0130 // Namespace does not match folder structure /// -/// Extension methods to register Azure CosmosDB NoSQL instances on an . +/// Extension methods to register Azure Cosmos NoSQL instances on an . /// -public static class CosmosNoSqlServiceCollectionExtensions +public static class CosmosServiceCollectionExtensions { private const string DynamicCodeMessage = "The Cosmos NoSQL provider is currently incompatible with NativeAOT."; private const string UnreferencedCodeMessage = "The Cosmos NoSQL provider is currently incompatible with trimming."; /// - /// Registers a as + /// Registers a as /// with retrieved from the dependency injection container. /// - /// + /// [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddCosmosNoSqlVectorStore( + public static IServiceCollection AddCosmosVectorStore( this IServiceCollection services, - CosmosNoSqlVectorStoreOptions? options = default, + CosmosVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) - => AddKeyedCosmosNoSqlVectorStore(services, serviceKey: null, options, lifetime); + => AddKeyedCosmosVectorStore(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 AddKeyedCosmosNoSqlVectorStore( + public static IServiceCollection AddKeyedCosmosVectorStore( this IServiceCollection services, object? serviceKey, - CosmosNoSqlVectorStoreOptions? options = default, + CosmosVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) { Throw.IfNull(services); - services.Add(new ServiceDescriptor(typeof(CosmosNoSqlVectorStore), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosVectorStore), serviceKey, (sp, _) => { var database = sp.GetRequiredService(); options = GetStoreOptions(sp, _ => options); - return new CosmosNoSqlVectorStore(database, options); + return new CosmosVectorStore(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 AddCosmosNoSqlVectorStore( + public static IServiceCollection AddCosmosVectorStore( this IServiceCollection services, string connectionString, string databaseName, - CosmosNoSqlVectorStoreOptions? options = default, + CosmosVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) - => AddKeyedCosmosNoSqlVectorStore(services, serviceKey: null, connectionString, databaseName, options, lifetime); + => AddKeyedCosmosVectorStore(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 NoSQL. - /// Database name for Azure CosmosDB NoSQL. - /// Optional options to further configure the . + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(DynamicCodeMessage)] [RequiresDynamicCode(UnreferencedCodeMessage)] - public static IServiceCollection AddKeyedCosmosNoSqlVectorStore( + public static IServiceCollection AddKeyedCosmosVectorStore( this IServiceCollection services, object? serviceKey, string connectionString, string databaseName, - CosmosNoSqlVectorStoreOptions? options = default, + CosmosVectorStoreOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) { Throw.IfNull(services); Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); - services.Add(new ServiceDescriptor(typeof(CosmosNoSqlVectorStore), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosVectorStore), serviceKey, (sp, _) => { options = GetStoreOptions(sp, _ => options); var clientOptions = CreateClientOptions(options?.JsonSerializerOptions); - return new CosmosNoSqlVectorStore(connectionString, databaseName, clientOptions, options); + return new CosmosVectorStore(connectionString, databaseName, clientOptions, 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 AddCosmosNoSqlCollection( + public static IServiceCollection AddCosmosCollection( this IServiceCollection services, string name, - CosmosNoSqlCollectionOptions? options = default, + CosmosCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosNoSqlCollection(services, serviceKey: null, name, options, lifetime); + => AddKeyedCosmosCollection(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 key. /// 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 AddKeyedCosmosNoSqlCollection( + public static IServiceCollection AddKeyedCosmosCollection( this IServiceCollection services, object? serviceKey, string name, - CosmosNoSqlCollectionOptions? options = default, + CosmosCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -164,12 +164,12 @@ public static IServiceCollection AddKeyedCosmosNoSqlCollection( Throw.IfNull(services); Throw.IfNullOrWhitespace(name); - services.Add(new ServiceDescriptor(typeof(CosmosNoSqlCollection), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosCollection), serviceKey, (sp, _) => { var database = sp.GetRequiredService(); options = GetCollectionOptions(sp, _ => options); - return new CosmosNoSqlCollection(database, name, options); + return new CosmosCollection(database, name, options); }, lifetime)); AddAbstractions(services, serviceKey, lifetime); @@ -178,46 +178,46 @@ public static IServiceCollection AddKeyedCosmosNoSqlCollection( } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddCosmosNoSqlCollection( + public static IServiceCollection AddCosmosCollection( this IServiceCollection services, string name, string connectionString, string databaseName, - CosmosNoSqlCollectionOptions? options = default, + CosmosCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosNoSqlCollection(services, serviceKey: null, name, connectionString, databaseName, options, lifetime); + => AddKeyedCosmosCollection(services, serviceKey: null, name, connectionString, databaseName, options, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// /// The type of the key. /// 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 NoSQL. - /// Database name for Azure CosmosDB NoSQL. - /// Optional options to further configure the . + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. + /// Optional options to further configure the . /// The service lifetime for the store. Defaults to . /// Service collection. [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddKeyedCosmosNoSqlCollection( + public static IServiceCollection AddKeyedCosmosCollection( this IServiceCollection services, object? serviceKey, string name, string connectionString, string databaseName, - CosmosNoSqlCollectionOptions? options = default, + CosmosCollectionOptions? options = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -225,29 +225,29 @@ public static IServiceCollection AddKeyedCosmosNoSqlCollection( Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); - return AddKeyedCosmosNoSqlCollection(services, serviceKey, name, _ => connectionString, _ => databaseName, _ => options!, lifetime); + return AddKeyedCosmosCollection(services, serviceKey, name, _ => connectionString, _ => databaseName, _ => options!, lifetime); } /// - /// Registers a as + /// Registers a as /// using the provided and . /// - /// + /// [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddCosmosNoSqlCollection( + public static IServiceCollection AddCosmosCollection( this IServiceCollection services, string name, Func connectionStringProvider, Func databaseNameProvider, - Func? optionsProvider = default, + Func? optionsProvider = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class - => AddKeyedCosmosNoSqlCollection(services, serviceKey: null, name, connectionStringProvider, databaseNameProvider, optionsProvider, lifetime); + => AddKeyedCosmosCollection(services, serviceKey: null, name, connectionStringProvider, databaseNameProvider, optionsProvider, lifetime); /// - /// Registers a keyed as + /// Registers a keyed as /// using the provided and . /// /// The type of the key. @@ -262,13 +262,13 @@ public static IServiceCollection AddCosmosNoSqlCollection( /// Service collection. [RequiresUnreferencedCode(UnreferencedCodeMessage)] [RequiresDynamicCode(DynamicCodeMessage)] - public static IServiceCollection AddKeyedCosmosNoSqlCollection( + public static IServiceCollection AddKeyedCosmosCollection( this IServiceCollection services, object? serviceKey, string name, Func connectionStringProvider, Func databaseNameProvider, - Func? optionsProvider = default, + Func? optionsProvider = default, ServiceLifetime lifetime = ServiceLifetime.Singleton) where TKey : notnull where TRecord : class @@ -278,12 +278,12 @@ public static IServiceCollection AddKeyedCosmosNoSqlCollection( Throw.IfNull(connectionStringProvider); Throw.IfNull(databaseNameProvider); - services.Add(new ServiceDescriptor(typeof(CosmosNoSqlCollection), serviceKey, (sp, _) => + services.Add(new ServiceDescriptor(typeof(CosmosCollection), serviceKey, (sp, _) => { var options = GetCollectionOptions(sp, optionsProvider); var clientOptions = CreateClientOptions(options?.JsonSerializerOptions); - return new CosmosNoSqlCollection( + return new CosmosCollection( connectionString: connectionStringProvider(sp), databaseName: databaseNameProvider(sp), name: name, @@ -301,16 +301,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)); services.Add(new ServiceDescriptor(typeof(IKeywordHybridSearchable), serviceKey, - static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); + static (sp, key) => sp.GetRequiredKeyedService>(key), lifetime)); } - private static CosmosNoSqlVectorStoreOptions? GetStoreOptions(IServiceProvider sp, Func? optionsProvider) + private static CosmosVectorStoreOptions? GetStoreOptions(IServiceProvider sp, Func? optionsProvider) { var options = optionsProvider?.Invoke(sp); if (options?.EmbeddingGenerator is not null) @@ -324,7 +324,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 CosmosNoSqlCollectionOptions? GetCollectionOptions(IServiceProvider sp, Func? optionsProvider) + private static CosmosCollectionOptions? GetCollectionOptions(IServiceProvider sp, Func? optionsProvider) { var options = optionsProvider?.Invoke(sp); if (options?.EmbeddingGenerator is not null) @@ -340,7 +340,7 @@ private static void AddAbstractions(IServiceCollection services, private static CosmosClientOptions CreateClientOptions(JsonSerializerOptions? jsonSerializerOptions) => new() { - ApplicationName = "CommunityToolkit.VectorData.CosmosNoSql", + ApplicationName = "CommunityToolkit.VectorData.AzureCosmosDB", UseSystemTextJsonSerializerWithOptions = jsonSerializerOptions ?? JsonSerializerOptions.Default, }; } diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlVectorStore.cs b/MEVD/src/AzureCosmosDB/CosmosVectorStore.cs similarity index 83% rename from MEVD/src/CosmosNoSql/CosmosNoSqlVectorStore.cs rename to MEVD/src/AzureCosmosDB/CosmosVectorStore.cs index 020fb57..712bfe1 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlVectorStore.cs +++ b/MEVD/src/AzureCosmosDB/CosmosVectorStore.cs @@ -15,20 +15,20 @@ using Microsoft.Extensions.VectorData.ProviderServices; using Microsoft.Shared.Diagnostics; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Class for accessing the list of collections in a Azure CosmosDB NoSQL vector store. +/// Class for accessing the list of collections in a Azure Cosmos NoSQL 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 CosmosNoSqlVectorStore : VectorStore +public sealed class CosmosVectorStore : VectorStore { /// Metadata about vector store. private readonly VectorStoreMetadata _metadata; - /// that can be used to manage the collections in Azure CosmosDB NoSQL. + /// that can be used to manage the collections in Azure Cosmos NoSQL. private readonly Database _database; private readonly ClientWrapper _clientWrapper; @@ -40,35 +40,35 @@ public sealed class CosmosNoSqlVectorStore : 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 NoSQL. + /// that can be used to manage the collections in Azure Cosmos NoSQL. /// Optional configuration options for this class. [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] - public CosmosNoSqlVectorStore(Database database, CosmosNoSqlVectorStoreOptions? options = null) + public CosmosVectorStore(Database database, CosmosVectorStoreOptions? options = null) : this(new(database.Client, ownsClient: false), _ => database, options) { Throw.IfNull(database); } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - /// Connection string required to connect to Azure CosmosDB NoSQL. - /// Database name for Azure CosmosDB NoSQL. + /// Connection string required to connect to Azure Cosmos NoSQL. + /// Database name for Azure Cosmos NoSQL. /// Optional configuration options for . /// Optional configuration options for . - public CosmosNoSqlVectorStore(string connectionString, string databaseName, - CosmosClientOptions? clientOptions = null, CosmosNoSqlVectorStoreOptions? storeOptions = null) + public CosmosVectorStore(string connectionString, string databaseName, + CosmosClientOptions? clientOptions = null, CosmosVectorStoreOptions? storeOptions = null) : this(new ClientWrapper(new CosmosClient(connectionString, clientOptions), ownsClient: true), client => client.GetDatabase(databaseName), storeOptions) { Throw.IfNullOrWhitespace(connectionString); Throw.IfNullOrWhitespace(databaseName); } - private CosmosNoSqlVectorStore(ClientWrapper clientWrapper, - Func databaseProvider, CosmosNoSqlVectorStoreOptions? options) + private CosmosVectorStore(ClientWrapper clientWrapper, + Func databaseProvider, CosmosVectorStoreOptions? options) { try { @@ -78,7 +78,7 @@ private CosmosNoSqlVectorStore(ClientWrapper clientWrapper, this._metadata = new() { - VectorStoreSystemName = CosmosNoSqlConstants.VectorStoreSystemName, + VectorStoreSystemName = CosmosConstants.VectorStoreSystemName, VectorStoreName = this._database.Id }; } @@ -105,13 +105,13 @@ protected override void Dispose(bool disposing) [RequiresUnreferencedCode("The Cosmos NoSQL provider is currently incompatible with trimming.")] [RequiresDynamicCode("The Cosmos NoSQL provider is currently incompatible with NativeAOT.")] #if NET - public override CosmosNoSqlCollection GetCollection(string name, VectorStoreCollectionDefinition? definition = null) + public override CosmosCollection 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 CosmosNoSqlCollection( + : new CosmosCollection( this._clientWrapper.Share(), _ => this._database, name, @@ -126,11 +126,11 @@ public override VectorStoreCollection GetCollection> GetDynamicCollection(string name, VectorStoreCollectionDefinition definition) #endif - => new CosmosNoSqlDynamicCollection( + => new CosmosDynamicCollection( this._clientWrapper.Share(), _ => this._database, name, diff --git a/MEVD/src/CosmosNoSql/CosmosNoSqlVectorStoreOptions.cs b/MEVD/src/AzureCosmosDB/CosmosVectorStoreOptions.cs similarity index 64% rename from MEVD/src/CosmosNoSql/CosmosNoSqlVectorStoreOptions.cs rename to MEVD/src/AzureCosmosDB/CosmosVectorStoreOptions.cs index 76c8765..fe0ff8e 100644 --- a/MEVD/src/CosmosNoSql/CosmosNoSqlVectorStoreOptions.cs +++ b/MEVD/src/AzureCosmosDB/CosmosVectorStoreOptions.cs @@ -4,28 +4,28 @@ using System.Text.Json; using Microsoft.Extensions.AI; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; /// -/// Options when creating a . +/// Options when creating a . /// -public sealed class CosmosNoSqlVectorStoreOptions +public sealed class CosmosVectorStoreOptions { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// - public CosmosNoSqlVectorStoreOptions() + public CosmosVectorStoreOptions() { } - internal CosmosNoSqlVectorStoreOptions(CosmosNoSqlVectorStoreOptions? source) + internal CosmosVectorStoreOptions(CosmosVectorStoreOptions? source) { this.JsonSerializerOptions = source?.JsonSerializerOptions; this.EmbeddingGenerator = source?.EmbeddingGenerator; } /// - /// Gets or sets the JSON serializer options to use when converting between the data model and the Azure CosmosDB NoSQL record. + /// Gets or sets the JSON serializer options to use when converting between the data model and the Azure Cosmos NoSQL record. /// public JsonSerializerOptions? JsonSerializerOptions { get; set; } diff --git a/MEVD/src/CosmosNoSql/ErrorHandlingFeedIterator.cs b/MEVD/src/AzureCosmosDB/ErrorHandlingFeedIterator.cs similarity index 97% rename from MEVD/src/CosmosNoSql/ErrorHandlingFeedIterator.cs rename to MEVD/src/AzureCosmosDB/ErrorHandlingFeedIterator.cs index e79d760..802ef7c 100644 --- a/MEVD/src/CosmosNoSql/ErrorHandlingFeedIterator.cs +++ b/MEVD/src/AzureCosmosDB/ErrorHandlingFeedIterator.cs @@ -6,7 +6,7 @@ using Microsoft.Azure.Cosmos; using Microsoft.Extensions.VectorData; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; internal class ErrorHandlingFeedIterator : FeedIterator { diff --git a/MEVD/src/CosmosNoSql/ICosmosNoSQLMapper.cs b/MEVD/src/AzureCosmosDB/ICosmosMapper.cs similarity index 87% rename from MEVD/src/CosmosNoSql/ICosmosNoSQLMapper.cs rename to MEVD/src/AzureCosmosDB/ICosmosMapper.cs index 957fcaa..2d57569 100644 --- a/MEVD/src/CosmosNoSql/ICosmosNoSQLMapper.cs +++ b/MEVD/src/AzureCosmosDB/ICosmosMapper.cs @@ -5,9 +5,9 @@ using System.Text.Json.Nodes; using MEAI = Microsoft.Extensions.AI; -namespace CommunityToolkit.VectorData.CosmosNoSql; +namespace CommunityToolkit.VectorData.AzureCosmosDB; -internal interface ICosmosNoSqlMapper +internal interface ICosmosMapper { /// /// Maps from the consumer record data model to the storage model. diff --git a/MEVD/src/CosmosNoSql/README.md b/MEVD/src/AzureCosmosDB/README.md similarity index 74% rename from MEVD/src/CosmosNoSql/README.md rename to MEVD/src/AzureCosmosDB/README.md index aba66f3..40f73b9 100644 --- a/MEVD/src/CosmosNoSql/README.md +++ b/MEVD/src/AzureCosmosDB/README.md @@ -1,24 +1,24 @@ -# CommunityToolkit.VectorData.CosmosNoSql +# CommunityToolkit.VectorData.AzureCosmosDB -`CommunityToolkit.VectorData.CosmosNoSql` is the Azure Cosmos DB for NoSQL provider for `Microsoft.Extensions.VectorData`. +`CommunityToolkit.VectorData.AzureCosmosDB` is the Azure Cosmos DB for NoSQL provider for `Microsoft.Extensions.VectorData`. ## Install ```xml - + ``` ## Get started ```csharp using Microsoft.Azure.Cosmos; -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Extensions.VectorData; CosmosClient client = new(""); Database database = client.GetDatabase("vector-database"); -VectorStore vectorStore = new CosmosNoSqlVectorStore(database); +VectorStore vectorStore = new CosmosVectorStore(database); VectorStoreCollection collection = vectorStore.GetCollection("hotels"); ``` @@ -28,8 +28,8 @@ You can also register the provider with dependency injection: ```csharp using Microsoft.Extensions.DependencyInjection; -services.AddCosmosNoSqlVectorStore("", "vector-database"); -services.AddCosmosNoSqlCollection( +services.AddCosmosVectorStore("", "vector-database"); +services.AddCosmosCollection( name: "hotels", connectionString: "", databaseName: "vector-database"); diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj b/MEVD/test/AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj similarity index 83% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj rename to MEVD/test/AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj index b0552db..2faa0b7 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSql.ConformanceTests.csproj +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/AzureCosmosDB.ConformanceTests.csproj @@ -6,7 +6,7 @@ enable true false - CosmosNoSql.ConformanceTests + AzureCosmosDB.ConformanceTests @@ -17,7 +17,7 @@ - + diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosBasicModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosBasicModelTests.cs new file mode 100644 index 0000000..bc91727 --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosBasicModelTests.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureCosmosDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosBasicModelTests(CosmosBasicModelTests.Fixture fixture) + : BasicModelTests(fixture), IClassFixture +{ + public override Task SearchAsync_with_Skip() + { + Assert.SkipUnless(!((CosmosTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); + + return base.SearchAsync_with_Skip(); + } + + public new sealed class Fixture : BasicModelTests.Fixture + { + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosBasicModelTests))); + + public override TestStore TestStore => _store.Value; + } +} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlCollectionManagementTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosCollectionManagementTests.cs similarity index 57% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlCollectionManagementTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosCollectionManagementTests.cs index 5c3664e..aa4814f 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlCollectionManagementTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosCollectionManagementTests.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 CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlCollectionManagementTests(CosmosNoSqlFixture fixture) - : CollectionManagementTests(fixture), IClassFixture +public sealed class CosmosCollectionManagementTests(CosmosFixture fixture) + : CollectionManagementTests(fixture), IClassFixture { } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDataTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDataTypeTests.cs similarity index 70% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDataTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDataTypeTests.cs index 26357bd..7e3444b 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDataTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDataTypeTests.cs @@ -1,23 +1,23 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosNoSqlDataTypeTests(CosmosNoSqlDataTypeTests.Fixture fixture) - : DataTypeTests.DefaultRecord>(fixture), IClassFixture +internal sealed class CosmosDataTypeTests(CosmosDataTypeTests.Fixture fixture) + : DataTypeTests.DefaultRecord>(fixture), IClassFixture { public override Task DateTimeOffset() => Task.CompletedTask; public new sealed class Fixture : DataTypeTests.DefaultRecord>.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlDataTypeTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosDataTypeTests))); public override TestStore TestStore => _store.Value; diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDependencyInjectionTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDependencyInjectionTests.cs similarity index 52% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDependencyInjectionTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDependencyInjectionTests.cs index d269e77..73a426d 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDependencyInjectionTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDependencyInjectionTests.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 CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using VectorData.ConformanceTests; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlDependencyInjectionTests - : DependencyInjectionTests.Record>, string, DependencyInjectionTests.Record> +public sealed class CosmosDependencyInjectionTests + : DependencyInjectionTests.Record>, string, DependencyInjectionTests.Record> { private const string TestConnectionString = "AccountEndpoint=https://localhost:8081;AccountKey=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="; @@ -18,8 +18,8 @@ public sealed class CosmosNoSqlDependencyInjectionTests get { yield return (services, serviceKey, lifetime) => serviceKey is null - ? services.AddCosmosNoSqlVectorStore(TestConnectionString, nameof(CosmosNoSqlDependencyInjectionTests), lifetime: lifetime) - : services.AddKeyedCosmosNoSqlVectorStore(serviceKey, TestConnectionString, nameof(CosmosNoSqlDependencyInjectionTests), lifetime: lifetime); + ? services.AddCosmosVectorStore(TestConnectionString, nameof(CosmosDependencyInjectionTests), lifetime: lifetime) + : services.AddKeyedCosmosVectorStore(serviceKey, TestConnectionString, nameof(CosmosDependencyInjectionTests), lifetime: lifetime); } } @@ -28,8 +28,8 @@ public sealed class CosmosNoSqlDependencyInjectionTests get { yield return (services, serviceKey, name, lifetime) => serviceKey is null - ? services.AddCosmosNoSqlCollection(name, TestConnectionString, nameof(CosmosNoSqlDependencyInjectionTests), lifetime: lifetime) - : services.AddKeyedCosmosNoSqlCollection(serviceKey, name, TestConnectionString, nameof(CosmosNoSqlDependencyInjectionTests), lifetime: lifetime); + ? services.AddCosmosCollection(name, TestConnectionString, nameof(CosmosDependencyInjectionTests), lifetime: lifetime) + : services.AddKeyedCosmosCollection(serviceKey, name, TestConnectionString, nameof(CosmosDependencyInjectionTests), lifetime: lifetime); } } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDistanceFunctionTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDistanceFunctionTests.cs similarity index 69% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDistanceFunctionTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDistanceFunctionTests.cs index b847702..d240533 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDistanceFunctionTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDistanceFunctionTests.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 CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlDistanceFunctionTests(CosmosNoSqlDistanceFunctionTests.Fixture fixture) - : DistanceFunctionTests(fixture), IClassFixture +public sealed class CosmosDistanceFunctionTests(CosmosDistanceFunctionTests.Fixture fixture) + : DistanceFunctionTests(fixture), IClassFixture { public override Task CosineDistance() => Assert.ThrowsAsync(base.CosineDistance); public override Task EuclideanSquaredDistance() => Assert.ThrowsAsync(base.EuclideanSquaredDistance); @@ -19,14 +19,14 @@ public sealed class CosmosNoSqlDistanceFunctionTests(CosmosNoSqlDistanceFunction public override Task EuclideanDistance() { - Assert.SkipUnless(!((CosmosNoSqlTestStore)fixture.TestStore).UsesLocalEmulator, "Fails on emulator, most likely due to emulator bug"); + Assert.SkipUnless(!((CosmosTestStore)fixture.TestStore).UsesLocalEmulator, "Fails on emulator, most likely due to emulator bug"); return base.EuclideanDistance(); } public new sealed class Fixture : DistanceFunctionTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlDistanceFunctionTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosDistanceFunctionTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDynamicModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDynamicModelTests.cs similarity index 50% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDynamicModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDynamicModelTests.cs index 20cdc0c..a9b8e3b 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlDynamicModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosDynamicModelTests.cs @@ -1,27 +1,27 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.ModelTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlDynamicModelTests(CosmosNoSqlDynamicModelTests.Fixture fixture) - : DynamicModelTests(fixture), IClassFixture +public sealed class CosmosDynamicModelTests(CosmosDynamicModelTests.Fixture fixture) + : DynamicModelTests(fixture), IClassFixture { public override Task SearchAsync_with_Skip() { // The vNext emulator's DiskANN index does not support OFFSET in vector search. - Assert.SkipUnless(!((CosmosNoSqlTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); + Assert.SkipUnless(!((CosmosTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); return base.SearchAsync_with_Skip(); } public new sealed class Fixture : DynamicModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlDynamicModelTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosDynamicModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingGenerationTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingGenerationTests.cs new file mode 100644 index 0000000..716dfc8 --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingGenerationTests.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureCosmosDB.ConformanceTests.Support; +using CommunityToolkit.VectorData.AzureCosmosDB; +using Microsoft.Extensions.AI; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.VectorData; +using VectorData.ConformanceTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosEmbeddingGenerationTests( + CosmosEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, + CosmosEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture) + : EmbeddingGenerationTests(stringVectorFixture, romOfFloatVectorFixture), + IClassFixture, + IClassFixture +{ + public new sealed class StringVectorFixture : EmbeddingGenerationTests.StringVectorFixture + { + public override string DefaultIndexKind => "DiskAnn"; + + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosEmbeddingGenerationTests))); + + public override TestStore TestStore => _store.Value; + + public override VectorStoreCollectionDefinition CreateRecordDefinition() + => CosmosConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); + + public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) + => new CosmosVectorStore( + ((CosmosTestStore)TestStore).Database, + new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosTestStore.SerializerOptions }); + + public override Func[] DependencyInjectionStoreRegistrationDelegates => + [ + services => services + .AddSingleton(((CosmosTestStore)TestStore).Database) + .AddCosmosVectorStore(new() + { + JsonSerializerOptions = CosmosTestStore.SerializerOptions, + }), + ]; + + public override Func[] DependencyInjectionCollectionRegistrationDelegates => + [ + services => services + .AddSingleton(((CosmosTestStore)TestStore).Database) + .AddCosmosCollection(CollectionName, new() + { + JsonSerializerOptions = CosmosTestStore.SerializerOptions, + }), + ]; + } + + public new sealed class RomOfFloatVectorFixture : EmbeddingGenerationTests.RomOfFloatVectorFixture + { + public override string DefaultIndexKind => "DiskAnn"; + + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosEmbeddingGenerationTests))); + + public override TestStore TestStore => _store.Value; + + public override VectorStoreCollectionDefinition CreateRecordDefinition() + => CosmosConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); + + public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) + => new CosmosVectorStore( + ((CosmosTestStore)TestStore).Database, + new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosTestStore.SerializerOptions }); + + public override Func[] DependencyInjectionStoreRegistrationDelegates => + [ + services => services.AddCosmosVectorStore( + ((CosmosTestStore)TestStore).ConnectionString, + nameof(CosmosEmbeddingGenerationTests), + new() { JsonSerializerOptions = CosmosTestStore.SerializerOptions }) + ]; + + public override Func[] DependencyInjectionCollectionRegistrationDelegates => + [ + services => services.AddCosmosCollection( + CollectionName, + ((CosmosTestStore)TestStore).ConnectionString, + nameof(CosmosEmbeddingGenerationTests), + new() { JsonSerializerOptions = CosmosTestStore.SerializerOptions }) + ]; + } +} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingTypeTests.cs similarity index 64% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingTypeTests.cs index d551e7f..777d588 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosEmbeddingTypeTests.cs @@ -1,23 +1,23 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using Microsoft.Extensions.AI; using Microsoft.Extensions.VectorData; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlEmbeddingTypeTests(CosmosNoSqlEmbeddingTypeTests.Fixture fixture) - : EmbeddingTypeTests(fixture), IClassFixture +public sealed class CosmosEmbeddingTypeTests(CosmosEmbeddingTypeTests.Fixture fixture) + : EmbeddingTypeTests(fixture), IClassFixture { public new sealed class Fixture : EmbeddingTypeTests.Fixture { public override string DefaultIndexKind => "DiskAnn"; - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlEmbeddingTypeTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosEmbeddingTypeTests))); public override TestStore TestStore => _store.Value; @@ -25,7 +25,7 @@ public override VectorStoreCollectionDefinition CreateRecordDefinition CosmosNoSqlConformanceTestHelpers.UseLowerCaseVectorStorageName( + => CosmosConformanceTestHelpers.UseLowerCaseVectorStorageName( base.CreateRecordDefinition(embeddingGenerator, distanceFunction, dimensions), "vector"); } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlFilterTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosFilterTests.cs similarity index 54% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlFilterTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosFilterTests.cs index 5e95100..dae2942 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlFilterTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosFilterTests.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 CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosNoSqlFilterTests(CosmosNoSqlFilterTests.Fixture fixture) - : FilterTests(fixture), IClassFixture +internal sealed class CosmosFilterTests(CosmosFilterTests.Fixture fixture) + : FilterTests(fixture), IClassFixture { public new sealed class Fixture : FilterTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlFilterTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosFilterTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlHybridSearchTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosHybridSearchTests.cs similarity index 51% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlHybridSearchTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosHybridSearchTests.cs index 94151ee..7488846 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlHybridSearchTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosHybridSearchTests.cs @@ -1,31 +1,31 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; // The type is internal to disable the tests due to emulator limitations -internal sealed class CosmosNoSqlHybridSearchTests( - CosmosNoSqlHybridSearchTests.VectorAndStringFixture vectorAndStringFixture, - CosmosNoSqlHybridSearchTests.MultiTextFixture multiTextFixture) +internal sealed class CosmosHybridSearchTests( + CosmosHybridSearchTests.VectorAndStringFixture vectorAndStringFixture, + CosmosHybridSearchTests.MultiTextFixture multiTextFixture) : HybridSearchTests(vectorAndStringFixture, multiTextFixture), - IClassFixture, - IClassFixture + IClassFixture, + IClassFixture { public new sealed class VectorAndStringFixture : HybridSearchTests.VectorAndStringFixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(VectorAndStringFixture))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(VectorAndStringFixture))); public override TestStore TestStore => _store.Value; } public new sealed class MultiTextFixture : HybridSearchTests.MultiTextFixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(MultiTextFixture))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(MultiTextFixture))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosIndexKindTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosIndexKindTests.cs new file mode 100644 index 0000000..5c9ce24 --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosIndexKindTests.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using AzureCosmosDB.ConformanceTests.Support; +using VectorData.ConformanceTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosIndexKindTests(CosmosIndexKindTests.Fixture fixture) + : IndexKindTests(fixture), IClassFixture +{ + [Fact] + public Task DiskAnn() => Test("DiskAnn"); + + public override Task Flat() + { + Assert.SkipUnless(!((CosmosTestStore)fixture.TestStore).UsesLocalEmulator, "Not supported on emulator."); + + return base.Flat(); + } + + public new sealed class Fixture : IndexKindTests.Fixture + { + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosIndexKindTests))); + + public override TestStore TestStore => _store.Value; + } +} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlKeyTypeTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosKeyTypeTests.cs similarity index 50% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlKeyTypeTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosKeyTypeTests.cs index 57a46ed..b88e4bc 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlKeyTypeTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosKeyTypeTests.cs @@ -1,19 +1,19 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.Support; using VectorData.ConformanceTests.TypeTests; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlKeyTypeTests(CosmosNoSqlKeyTypeTests.Fixture fixture) - : KeyTypeTests(fixture), IClassFixture +public sealed class CosmosKeyTypeTests(CosmosKeyTypeTests.Fixture fixture) + : KeyTypeTests(fixture), IClassFixture { public new sealed class Fixture : KeyTypeTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlKeyTypeTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosKeyTypeTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlMultiVectorModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosMultiVectorModelTests.cs similarity index 56% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlMultiVectorModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosMultiVectorModelTests.cs index 659f76e..1740295 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlMultiVectorModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosMultiVectorModelTests.cs @@ -1,19 +1,19 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.ModelTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlMultiVectorModelTests(CosmosNoSqlMultiVectorModelTests.Fixture fixture) - : MultiVectorModelTests(fixture), IClassFixture +public sealed class CosmosMultiVectorModelTests(CosmosMultiVectorModelTests.Fixture fixture) + : MultiVectorModelTests(fixture), IClassFixture { public new sealed class Fixture : MultiVectorModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlMultiVectorModelTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosMultiVectorModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoDataModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoDataModelTests.cs new file mode 100644 index 0000000..4cc91bf --- /dev/null +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoDataModelTests.cs @@ -0,0 +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 AzureCosmosDB.ConformanceTests.Support; +using VectorData.ConformanceTests.ModelTests; +using VectorData.ConformanceTests.Support; +using Xunit; + +namespace AzureCosmosDB.ConformanceTests; + +public sealed class CosmosNoDataModelTests(CosmosNoDataModelTests.Fixture fixture) + : NoDataModelTests(fixture), IClassFixture +{ + public new sealed class Fixture : NoDataModelTests.Fixture + { + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosNoDataModelTests))); + + public override TestStore TestStore => _store.Value; + } +} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoVectorModelTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoVectorModelTests.cs similarity index 57% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoVectorModelTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoVectorModelTests.cs index 7268f04..2cfc2b6 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoVectorModelTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosNoVectorModelTests.cs @@ -1,19 +1,19 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using CosmosNoSql.ConformanceTests.Support; +using AzureCosmosDB.ConformanceTests.Support; using VectorData.ConformanceTests.ModelTests; using VectorData.ConformanceTests.Support; using Xunit; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlNoVectorModelTests(CosmosNoSqlNoVectorModelTests.Fixture fixture) - : NoVectorModelTests(fixture), IClassFixture +public sealed class CosmosNoVectorModelTests(CosmosNoVectorModelTests.Fixture fixture) + : NoVectorModelTests(fixture), IClassFixture { public new sealed class Fixture : NoVectorModelTests.Fixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlNoVectorModelTests))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosNoVectorModelTests))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlTestSuiteImplementationTests.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosTestSuiteImplementationTests.cs similarity index 79% rename from MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlTestSuiteImplementationTests.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/CosmosTestSuiteImplementationTests.cs index a84ae45..80ba470 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlTestSuiteImplementationTests.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/CosmosTestSuiteImplementationTests.cs @@ -4,9 +4,9 @@ using VectorData.ConformanceTests; using VectorData.ConformanceTests.TypeTests; -namespace CosmosNoSql.ConformanceTests; +namespace AzureCosmosDB.ConformanceTests; -public sealed class CosmosNoSqlTestSuiteImplementationTests : TestSuiteImplementationTests +public sealed class CosmosTestSuiteImplementationTests : TestSuiteImplementationTests { protected override ICollection IgnoredTestBases { get; } = [ diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlConformanceTestHelpers.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosConformanceTestHelpers.cs similarity index 84% rename from MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlConformanceTestHelpers.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosConformanceTestHelpers.cs index 91d2106..536e4a4 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlConformanceTestHelpers.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosConformanceTestHelpers.cs @@ -3,9 +3,9 @@ using Microsoft.Extensions.VectorData; -namespace CosmosNoSql.ConformanceTests.Support; +namespace AzureCosmosDB.ConformanceTests.Support; -internal static class CosmosNoSqlConformanceTestHelpers +internal static class CosmosConformanceTestHelpers { public static VectorStoreCollectionDefinition UseLowerCaseVectorStorageName( VectorStoreCollectionDefinition definition, diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlFixture.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosFixture.cs similarity index 51% rename from MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlFixture.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosFixture.cs index f57f66c..80518f6 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlFixture.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosFixture.cs @@ -3,11 +3,11 @@ using VectorData.ConformanceTests.Support; -namespace CosmosNoSql.ConformanceTests.Support; +namespace AzureCosmosDB.ConformanceTests.Support; -public sealed class CosmosNoSqlFixture : VectorStoreFixture +public sealed class CosmosFixture : VectorStoreFixture { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlFixture))); + private readonly Lazy _store = new(() => new CosmosTestStore(nameof(CosmosFixture))); public override TestStore TestStore => _store.Value; } diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestEnvironment.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestEnvironment.cs similarity index 85% rename from MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestEnvironment.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestEnvironment.cs index faa6157..50d6eae 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestEnvironment.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestEnvironment.cs @@ -3,17 +3,17 @@ using Microsoft.Extensions.Configuration; -namespace CosmosNoSql.ConformanceTests.Support; +namespace AzureCosmosDB.ConformanceTests.Support; #pragma warning disable CA1810 // Initialize all static fields when those fields are declared -internal static class CosmosNoSqlTestEnvironment +internal static class CosmosTestEnvironment { public static readonly string? ConnectionString; public static bool IsConnectionStringDefined => ConnectionString is not null; - static CosmosNoSqlTestEnvironment() + static CosmosTestEnvironment() { var configuration = new ConfigurationBuilder() .AddJsonFile(path: "testsettings.json", optional: true) diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestStore.cs b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestStore.cs similarity index 86% rename from MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestStore.cs rename to MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestStore.cs index 0998d11..80d381b 100644 --- a/MEVD/test/CosmosNoSql.ConformanceTests/Support/CosmosNoSqlTestStore.cs +++ b/MEVD/test/AzureCosmosDB.ConformanceTests/Support/CosmosTestStore.cs @@ -2,18 +2,18 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Text.Json; -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Azure.Cosmos; using Microsoft.Extensions.VectorData; using Testcontainers.CosmosDb; using VectorData.ConformanceTests.Support; -namespace CosmosNoSql.ConformanceTests.Support; +namespace AzureCosmosDB.ConformanceTests.Support; #pragma warning disable CA1001 // Type owns disposable fields but is not disposable /// The emulator does not support running multiple queries simultaneously, so we create a unique database for each test store instance. -internal sealed class CosmosNoSqlTestStore(string uniqueDatabaseName) : TestStore +internal sealed class CosmosTestStore(string uniqueDatabaseName) : TestStore { private CosmosDbContainer? _container; private CosmosClient? _client; @@ -29,7 +29,7 @@ internal sealed class CosmosNoSqlTestStore(string uniqueDatabaseName) : TestStor public static JsonSerializerOptions SerializerOptions { get; } = new(JsonSerializerDefaults.Web) { - PropertyNamingPolicy = new CosmosNoSqlTestJsonNamingPolicy() + PropertyNamingPolicy = new CosmosTestJsonNamingPolicy() }; public Database Database => _database ?? throw new InvalidOperationException("Cosmos DB test store has not been started."); @@ -37,7 +37,7 @@ internal sealed class CosmosNoSqlTestStore(string uniqueDatabaseName) : TestStor public override VectorStoreCollection CreateCollection( string name, VectorStoreCollectionDefinition definition) - => new CosmosNoSqlCollection( + => new CosmosCollection( Database, name, new() @@ -49,7 +49,7 @@ public override VectorStoreCollection CreateCollection> CreateDynamicCollection( string name, VectorStoreCollectionDefinition definition) - => new CosmosNoSqlDynamicCollection( + => new CosmosDynamicCollection( Database, name, new() @@ -60,9 +60,9 @@ public override VectorStoreCollection CreateCollection CreateDatabaseWithRetryAsync() throw new TimeoutException("Cosmos DB did not become available within one minute."); } - private sealed class CosmosNoSqlTestJsonNamingPolicy : JsonNamingPolicy + private sealed class CosmosTestJsonNamingPolicy : JsonNamingPolicy { public override string ConvertName(string name) => name is "Vector" or "Embedding" diff --git a/MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj b/MEVD/test/AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj similarity index 72% rename from MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj rename to MEVD/test/AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj index a5a5be1..8a09eab 100644 --- a/MEVD/test/CosmosNoSql.UnitTests/CosmosNoSql.UnitTests.csproj +++ b/MEVD/test/AzureCosmosDB.UnitTests/AzureCosmosDB.UnitTests.csproj @@ -1,8 +1,8 @@  - CommunityToolkit.VectorData.CosmosNoSql.UnitTests - CommunityToolkit.VectorData.CosmosNoSql.UnitTests + CommunityToolkit.VectorData.AzureCosmosDB.UnitTests + CommunityToolkit.VectorData.AzureCosmosDB.UnitTests net10.0 true enable @@ -19,6 +19,6 @@ - + diff --git a/MEVD/test/CosmosNoSql.UnitTests/CosmosNoSqlOptionsTests.cs b/MEVD/test/AzureCosmosDB.UnitTests/CosmosOptionsTests.cs similarity index 83% rename from MEVD/test/CosmosNoSql.UnitTests/CosmosNoSqlOptionsTests.cs rename to MEVD/test/AzureCosmosDB.UnitTests/CosmosOptionsTests.cs index 3d5febf..3894d38 100644 --- a/MEVD/test/CosmosNoSql.UnitTests/CosmosNoSqlOptionsTests.cs +++ b/MEVD/test/AzureCosmosDB.UnitTests/CosmosOptionsTests.cs @@ -3,19 +3,19 @@ using System.Collections.Generic; using System.Text.Json; -using CommunityToolkit.VectorData.CosmosNoSql; +using CommunityToolkit.VectorData.AzureCosmosDB; using Microsoft.Azure.Cosmos; using Xunit; -namespace CommunityToolkit.VectorData.CosmosNoSql.UnitTests; +namespace CommunityToolkit.VectorData.AzureCosmosDB.UnitTests; -public sealed class CosmosNoSqlOptionsTests +public sealed class CosmosOptionsTests { [Fact] public void CollectionOptionsPropertiesCanBeConfigured() { JsonSerializerOptions serializerOptions = new(JsonSerializerDefaults.Web); - CosmosNoSqlCollectionOptions source = new() + CosmosCollectionOptions source = new() { JsonSerializerOptions = serializerOptions, PartitionKeyProperties = new[] { "tenantId", "category" }, @@ -35,7 +35,7 @@ public void CollectionOptionsPropertiesCanBeConfigured() public void VectorStoreOptionsPropertiesCanBeConfigured() { JsonSerializerOptions serializerOptions = new(JsonSerializerDefaults.Web); - CosmosNoSqlVectorStoreOptions source = new() + CosmosVectorStoreOptions source = new() { JsonSerializerOptions = serializerOptions, }; diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlBasicModelTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlBasicModelTests.cs deleted file mode 100644 index cc8b326..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlBasicModelTests.cs +++ /dev/null @@ -1,27 +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 CosmosNoSql.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlBasicModelTests(CosmosNoSqlBasicModelTests.Fixture fixture) - : BasicModelTests(fixture), IClassFixture -{ - public override Task SearchAsync_with_Skip() - { - Assert.SkipUnless(!((CosmosNoSqlTestStore)fixture.TestStore).UsesLocalEmulator, "The vNext emulator's DiskANN index does not support OFFSET in vector search."); - - return base.SearchAsync_with_Skip(); - } - - public new sealed class Fixture : BasicModelTests.Fixture - { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlBasicModelTests))); - - public override TestStore TestStore => _store.Value; - } -} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingGenerationTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingGenerationTests.cs deleted file mode 100644 index bf210af..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlEmbeddingGenerationTests.cs +++ /dev/null @@ -1,92 +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 CosmosNoSql.ConformanceTests.Support; -using CommunityToolkit.VectorData.CosmosNoSql; -using Microsoft.Extensions.AI; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.VectorData; -using VectorData.ConformanceTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlEmbeddingGenerationTests( - CosmosNoSqlEmbeddingGenerationTests.StringVectorFixture stringVectorFixture, - CosmosNoSqlEmbeddingGenerationTests.RomOfFloatVectorFixture romOfFloatVectorFixture) - : EmbeddingGenerationTests(stringVectorFixture, romOfFloatVectorFixture), - IClassFixture, - IClassFixture -{ - public new sealed class StringVectorFixture : EmbeddingGenerationTests.StringVectorFixture - { - public override string DefaultIndexKind => "DiskAnn"; - - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlEmbeddingGenerationTests))); - - public override TestStore TestStore => _store.Value; - - public override VectorStoreCollectionDefinition CreateRecordDefinition() - => CosmosNoSqlConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); - - public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) - => new CosmosNoSqlVectorStore( - ((CosmosNoSqlTestStore)TestStore).Database, - new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions }); - - public override Func[] DependencyInjectionStoreRegistrationDelegates => - [ - services => services - .AddSingleton(((CosmosNoSqlTestStore)TestStore).Database) - .AddCosmosNoSqlVectorStore(new() - { - JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions, - }), - ]; - - public override Func[] DependencyInjectionCollectionRegistrationDelegates => - [ - services => services - .AddSingleton(((CosmosNoSqlTestStore)TestStore).Database) - .AddCosmosNoSqlCollection(CollectionName, new() - { - JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions, - }), - ]; - } - - public new sealed class RomOfFloatVectorFixture : EmbeddingGenerationTests.RomOfFloatVectorFixture - { - public override string DefaultIndexKind => "DiskAnn"; - - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlEmbeddingGenerationTests))); - - public override TestStore TestStore => _store.Value; - - public override VectorStoreCollectionDefinition CreateRecordDefinition() - => CosmosNoSqlConformanceTestHelpers.UseLowerCaseVectorStorageName(base.CreateRecordDefinition(), "embedding"); - - public override VectorStore CreateVectorStore(IEmbeddingGenerator? embeddingGenerator = null) - => new CosmosNoSqlVectorStore( - ((CosmosNoSqlTestStore)TestStore).Database, - new() { EmbeddingGenerator = embeddingGenerator, JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions }); - - public override Func[] DependencyInjectionStoreRegistrationDelegates => - [ - services => services.AddCosmosNoSqlVectorStore( - ((CosmosNoSqlTestStore)TestStore).ConnectionString, - nameof(CosmosNoSqlEmbeddingGenerationTests), - new() { JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions }) - ]; - - public override Func[] DependencyInjectionCollectionRegistrationDelegates => - [ - services => services.AddCosmosNoSqlCollection( - CollectionName, - ((CosmosNoSqlTestStore)TestStore).ConnectionString, - nameof(CosmosNoSqlEmbeddingGenerationTests), - new() { JsonSerializerOptions = CosmosNoSqlTestStore.SerializerOptions }) - ]; - } -} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlIndexKindTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlIndexKindTests.cs deleted file mode 100644 index 0a68893..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlIndexKindTests.cs +++ /dev/null @@ -1,30 +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 CosmosNoSql.ConformanceTests.Support; -using VectorData.ConformanceTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlIndexKindTests(CosmosNoSqlIndexKindTests.Fixture fixture) - : IndexKindTests(fixture), IClassFixture -{ - [Fact] - public Task DiskAnn() => Test("DiskAnn"); - - public override Task Flat() - { - Assert.SkipUnless(!((CosmosNoSqlTestStore)fixture.TestStore).UsesLocalEmulator, "Not supported on emulator."); - - return base.Flat(); - } - - public new sealed class Fixture : IndexKindTests.Fixture - { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlIndexKindTests))); - - public override TestStore TestStore => _store.Value; - } -} diff --git a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoDataModelTests.cs b/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoDataModelTests.cs deleted file mode 100644 index 944fc09..0000000 --- a/MEVD/test/CosmosNoSql.ConformanceTests/CosmosNoSqlNoDataModelTests.cs +++ /dev/null @@ -1,20 +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 CosmosNoSql.ConformanceTests.Support; -using VectorData.ConformanceTests.ModelTests; -using VectorData.ConformanceTests.Support; -using Xunit; - -namespace CosmosNoSql.ConformanceTests; - -public sealed class CosmosNoSqlNoDataModelTests(CosmosNoSqlNoDataModelTests.Fixture fixture) - : NoDataModelTests(fixture), IClassFixture -{ - public new sealed class Fixture : NoDataModelTests.Fixture - { - private readonly Lazy _store = new(() => new CosmosNoSqlTestStore(nameof(CosmosNoSqlNoDataModelTests))); - - public override TestStore TestStore => _store.Value; - } -} diff --git a/README.md b/README.md index 10c9f03..3ef7a71 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ The following NuGet packages have been published: | Package | Version | Downloads | |---------|---------|-----------| | [CommunityToolkit.VectorData.AzureAISearch] | ![AzureAISearch Version][v-azureaisearch] | ![AzureAISearch Downloads][d-azureaisearch] | +| [CommunityToolkit.VectorData.AzureCosmosDB] | ![AzureCosmosDB Version][v-azurecosmosdb] | ![AzureCosmosDB Downloads][d-azurecosmosdb] | | [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] | | [CommunityToolkit.VectorData.Qdrant] | ![Qdrant Version][v-qdrant] | ![Qdrant Downloads][d-qdrant] | @@ -52,8 +52,8 @@ 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.AzureCosmosDB]: https://www.nuget.org/packages/CommunityToolkit.VectorData.AzureCosmosDB [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 [CommunityToolkit.VectorData.Qdrant]: https://www.nuget.org/packages/CommunityToolkit.VectorData.Qdrant @@ -64,8 +64,8 @@ The Vector Data connectors in this toolkit were initially part of the [Semantic [v-azureaisearch]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.AzureAISearch +[v-azurecosmosdb]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.AzureCosmosDB [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 [v-qdrant]: https://badgen.net/nuget/v/CommunityToolkit.VectorData.Qdrant @@ -76,8 +76,8 @@ The Vector Data connectors in this toolkit were initially part of the [Semantic [d-azureaisearch]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.AzureAISearch +[d-azurecosmosdb]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.AzureCosmosDB [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 [d-qdrant]: https://badgen.net/nuget/dt/CommunityToolkit.VectorData.Qdrant