Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dotnet/src/VectorData/CosmosMongoDB/CosmosMongoCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
namespace Microsoft.SemanticKernel.Connectors.CosmosMongoDB;

/// <summary>
/// Service for storing and retrieving vector records, that uses Azure CosmosDB MongoDB as the underlying storage.
/// Service for storing and retrieving vector records, that uses Azure DocumentDB (with MongoDB compatibility) as the underlying storage.
/// </summary>
/// <typeparam name="TKey">The data type of the record key. Must be either <see cref="string"/>.</typeparam>
/// <typeparam name="TRecord">The data model to use for adding, updating and retrieving data from storage.</typeparam>
Expand All @@ -44,10 +44,10 @@ public class CosmosMongoCollection<TKey, TRecord> : VectorStoreCollection<TKey,
/// <summary>The default options for vector search.</summary>
private static readonly MEVD.VectorSearchOptions<TRecord> s_defaultVectorSearchOptions = new();

/// <summary><see cref="IMongoDatabase"/> that can be used to manage the collections in Azure CosmosDB MongoDB.</summary>
/// <summary><see cref="IMongoDatabase"/> that can be used to manage the collections in Azure DocumentDB.</summary>
private readonly IMongoDatabase _mongoDatabase;

/// <summary>Azure CosmosDB MongoDB collection to perform record operations.</summary>
/// <summary>Azure DocumentDB collection to perform record operations.</summary>
private readonly IMongoCollection<BsonDocument> _mongoCollection;

/// <summary>Interface for mapping between a storage model, and the consumer record data model.</summary>
Expand Down Expand Up @@ -76,7 +76,7 @@ public class CosmosMongoCollection<TKey, TRecord> : VectorStoreCollection<TKey,
/// <summary>
/// Initializes a new instance of the <see cref="CosmosMongoCollection{TKey, TRecord}"/> class.
/// </summary>
/// <param name="mongoDatabase"><see cref="IMongoDatabase"/> that can be used to manage the collections in Azure CosmosDB MongoDB.</param>
/// <param name="mongoDatabase"><see cref="IMongoDatabase"/> that can be used to manage the collections in Azure DocumentDB.</param>
/// <param name="name">The name of the collection that this <see cref="CosmosMongoCollection{TKey, TRecord}"/> will access.</param>
/// <param name="options">Optional configuration options for this class.</param>
[RequiresDynamicCode("This constructor is incompatible with NativeAOT. For dynamic mapping via Dictionary<string, object?>, instantiate CosmosMongoDynamicCollection instead.")]
Expand Down Expand Up @@ -397,7 +397,7 @@ _ when vectorProperty.EmbeddingGenerationDispatcher is not null
itemsAmount,
filter),
_ => throw new InvalidOperationException(
$"Index kind '{vectorProperty.IndexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorProperty.StorageName}' is not supported by the Azure CosmosDB for MongoDB VectorStore. " +
$"Index kind '{vectorProperty.IndexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorProperty.StorageName}' is not supported by the Azure DocumentDB VectorStore. " +
$"Supported index kinds are: {string.Join(", ", [IndexKind.Hnsw, IndexKind.IvfFlat])}")
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace Microsoft.SemanticKernel.Connectors.CosmosMongoDB;

/// <summary>
/// Contains mapping helpers to use when creating a collection in Azure CosmosDB MongoDB.
/// Contains mapping helpers to use when creating a collection in Azure DocumentDB (with MongoDB compatibility).
/// </summary>
internal static class CosmosMongoCollectionCreateMapping
{
Expand Down Expand Up @@ -105,25 +105,25 @@ public static BsonArray GetFilterableDataIndexes(
}

/// <summary>
/// More information about Azure CosmosDB for MongoDB index kinds here: <see href="https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/vector-search" />.
/// More information about Azure DocumentDB index kinds here: <see href="https://learn.microsoft.com/en-us/azure/documentdb/vector-search" />.
/// </summary>
private static string GetIndexKind(string? indexKind, string vectorPropertyName)
=> CosmosMongoCollectionSearchMapping.GetVectorPropertyIndexKind(indexKind) switch
{
IndexKind.Hnsw => "vector-hnsw",
IndexKind.IvfFlat => "vector-ivf",
_ => throw new NotSupportedException($"Index kind '{indexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB for MongoDB VectorStore.")
_ => throw new NotSupportedException($"Index kind '{indexKind}' on {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure DocumentDB VectorStore.")
};

/// <summary>
/// More information about Azure CosmosDB for MongoDB distance functions here: <see href="https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/vector-search" />.
/// More information about Azure DocumentDB distance functions here: <see href="https://learn.microsoft.com/azure/documentdb/" />.
/// </summary>
Comment thread
khelanmodi marked this conversation as resolved.
private static string GetDistanceFunction(string? distanceFunction, string vectorPropertyName)
=> CosmosMongoCollectionSearchMapping.GetVectorPropertyDistanceFunction(distanceFunction) switch
{
DistanceFunction.CosineDistance => "COS",
DistanceFunction.DotProductSimilarity => "IP",
DistanceFunction.EuclideanDistance => "L2",
_ => throw new NotSupportedException($"Distance function '{distanceFunction}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure CosmosDB for MongoDB VectorStore.")
_ => throw new NotSupportedException($"Distance function '{distanceFunction}' for {nameof(VectorStoreVectorProperty)} '{vectorPropertyName}' is not supported by the Azure DocumentDB VectorStore.")
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.SemanticKernel.Connectors.CosmosMongoDB;

/// <summary>
/// Contains mapping helpers to use when searching for documents using Azure CosmosDB MongoDB.
/// Contains mapping helpers to use when searching for documents using Azure DocumentDB (with MongoDB compatibility).
/// </summary>
internal static class CosmosMongoCollectionSearchMapping
{
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/VectorData/CosmosMongoDB/CosmosMongoDB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

<PropertyGroup>
<!-- NuGet Package Settings -->
<Title>Azure CosmosDB MongoDB vCore provider for Microsoft.Extensions.VectorData</Title>
<Description>Azure CosmosDB MongoDB vCore provider for Microsoft.Extensions.VectorData by Semantic Kernel</Description>
<Title>Azure DocumentDB (with MongoDB compatibility) provider for Microsoft.Extensions.VectorData</Title>
<Description>Azure DocumentDB (with MongoDB compatibility) provider for Microsoft.Extensions.VectorData by Semantic Kernel</Description>
<PackageReadmeFile>VECTORDATA-CONNECTORS-NUGET.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Microsoft.Extensions.DependencyInjection;

/// <summary>
/// Extension methods to register Azure CosmosDB MongoDB <see cref="VectorStore"/> instances on an <see cref="IServiceCollection"/>.
/// Extension methods to register Azure DocumentDB (with MongoDB compatibility) <see cref="VectorStore"/> instances on an <see cref="IServiceCollection"/>.
/// </summary>
public static class CosmosMongoServiceCollectionExtensions
{
Expand Down Expand Up @@ -86,8 +86,8 @@ public static IServiceCollection AddCosmosMongoVectorStore(
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> to register the <see cref="CosmosMongoVectorStore"/> on.</param>
/// <param name="serviceKey">The key with which to associate the vector store.</param>
/// <param name="connectionString">Connection string required to connect to Azure CosmosDB MongoDB.</param>
/// <param name="databaseName">Database name for Azure CosmosDB MongoDB.</param>
/// <param name="connectionString">Connection string required to connect to Azure DocumentDB.</param>
/// <param name="databaseName">Database name for Azure DocumentDB.</param>
Comment on lines +89 to +90
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These contract docs now imply that any Azure DocumentDB endpoint is valid input, but this overload still creates a MongoClient and calls GetDatabase on the supplied values (CosmosMongoServiceCollectionExtensions.cs:111-113). The repo's active connector surface also remains explicitly MongoDB-specific (python/semantic_kernel/connectors/azure_cosmos_db.py:214-226), and the .NET DI tests use MongoDB connection strings here (dotnet/test/VectorData/CosmosMongoDB.ConformanceTests/CosmosMongoDependencyInjectionTests.cs:15, 43-45). For API-contract text like this, the shorthand drops an important constraint; keep the MongoDB-compatibility qualifier.

Suggested change
/// <param name="connectionString">Connection string required to connect to Azure DocumentDB.</param>
/// <param name="databaseName">Database name for Azure DocumentDB.</param>
/// <param name="connectionString">Connection string required to connect to Azure DocumentDB (with MongoDB compatibility).</param>
/// <param name="databaseName">Database name for Azure DocumentDB (with MongoDB compatibility).</param>

/// <param name="options">Optional options to further configure the <see cref="CosmosMongoVectorStore"/>.</param>
/// <param name="lifetime">The service lifetime for the store. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param>
/// <returns>Service collection.</returns>
Expand Down Expand Up @@ -197,8 +197,8 @@ public static IServiceCollection AddCosmosMongoCollection<TRecord>(
/// <param name="services">The <see cref="IServiceCollection"/> to register the <see cref="CosmosMongoCollection{TKey, TRecord}"/> on.</param>
/// <param name="serviceKey">The key with which to associate the collection.</param>
/// <param name="name">The name of the collection.</param>
/// <param name="connectionString">Connection string required to connect to Azure CosmosDB MongoDB.</param>
/// <param name="databaseName">Database name for Azure CosmosDB MongoDB.</param>
/// <param name="connectionString">Connection string required to connect to Azure DocumentDB.</param>
/// <param name="databaseName">Database name for Azure DocumentDB.</param>
/// <param name="options">Optional options to further configure the <see cref="CosmosMongoCollection{TKey, TRecord}"/>.</param>
/// <param name="lifetime">The service lifetime for the store. Defaults to <see cref="ServiceLifetime.Singleton"/>.</param>
/// <returns>Service collection.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace Microsoft.SemanticKernel.Connectors.CosmosMongoDB;

/// <summary>
/// Class for accessing the list of collections in a Azure CosmosDB MongoDB vector store.
/// Class for accessing the list of collections in an Azure DocumentDB (with MongoDB compatibility) vector store.
/// </summary>
/// <remarks>
/// This class can be used with collections of any schema type, but requires you to provide schema information when getting a collection.
Expand All @@ -25,7 +25,7 @@ public sealed class CosmosMongoVectorStore : VectorStore
/// <summary>Metadata about vector store.</summary>
private readonly VectorStoreMetadata _metadata;

/// <summary><see cref="IMongoDatabase"/> that can be used to manage the collections in Azure CosmosDB MongoDB.</summary>
/// <summary><see cref="IMongoDatabase"/> that can be used to manage the collections in Azure DocumentDB.</summary>
private readonly IMongoDatabase _mongoDatabase;

/// <summary>A general purpose definition that can be used to construct a collection when needing to proxy schema agnostic operations.</summary>
Expand All @@ -36,7 +36,7 @@ public sealed class CosmosMongoVectorStore : VectorStore
/// <summary>
/// Initializes a new instance of the <see cref="CosmosMongoVectorStore"/> class.
/// </summary>
/// <param name="mongoDatabase"><see cref="IMongoDatabase"/> that can be used to manage the collections in Azure CosmosDB MongoDB.</param>
/// <param name="mongoDatabase"><see cref="IMongoDatabase"/> that can be used to manage the collections in Azure DocumentDB.</param>
/// <param name="options">Optional configuration options for this class.</param>
public CosmosMongoVectorStore(IMongoDatabase mongoDatabase, CosmosMongoVectorStoreOptions? options = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@deprecated("This class will be removed in a future release, use AzureCosmosDBforMongoDBStore and Collection instead.")
class AzureCosmosDBMemoryStore(MemoryStoreBase):
"""A memory store that uses AzureCosmosDB for MongoDB vCore.
"""A memory store that uses Azure DocumentDB (with MongoDB compatibility).

To perform vector similarity search on a fully managed MongoDB compatible database service.
https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/vector-search.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@deprecated("This class will be removed in a future release.")
class MongoStoreApi(AzureCosmosDBStoreApi):
"""MongoStoreApi class for the Azure Cosmos DB Mongo store."""
"""MongoStoreApi class for the Azure DocumentDB (with MongoDB compatibility) store."""

database = None
collection_name: str
Expand All @@ -41,7 +41,7 @@ class MongoStoreApi(AzureCosmosDBStoreApi):

"""
Args:
collection_name: Name of the collection for the azure cosmos db mongo store
collection_name: Name of the collection for the Azure DocumentDB store
index_name: Index for the collection
vector_dimensions: Number of dimensions for vector similarity.
The maximum number of supported dimensions is 2000
Expand Down Expand Up @@ -74,7 +74,7 @@ class MongoStoreApi(AzureCosmosDBStoreApi):
ef_construction has to be at least 2 * m
ef_search: The size of the dynamic candidate list for search (40 by default).
A higher value provides better recall at the cost of speed.
database: The Mongo Database object of the azure cosmos db mongo store
database: The Mongo Database object of the Azure DocumentDB store
"""

def __init__(
Expand Down
Loading