diff --git a/dotnet/samples/Concepts/Caching/SemanticCachingWithFilters.cs b/dotnet/samples/Concepts/Caching/SemanticCachingWithFilters.cs
index 2f3cbb7181b1..cd90de3964b4 100644
--- a/dotnet/samples/Concepts/Caching/SemanticCachingWithFilters.cs
+++ b/dotnet/samples/Concepts/Caching/SemanticCachingWithFilters.cs
@@ -87,12 +87,7 @@ public async Task AzureCosmosDBMongoDBCacheAsync()
var kernel = GetKernelWithCache(_ => new AzureCosmosDBMongoDBMemoryStore(
TestConfiguration.AzureCosmosDbMongoDb.ConnectionString,
TestConfiguration.AzureCosmosDbMongoDb.DatabaseName,
- new()
- {
- Kind = AzureCosmosDBVectorSearchType.VectorIVF,
- Similarity = AzureCosmosDBSimilarityType.Cosine,
- Dimensions = 1536
- }));
+ new(dimensions: 1536)));
var result1 = await ExecuteAsync(kernel, "First run", "What's the tallest building in New York?");
var result2 = await ExecuteAsync(kernel, "Second run", "What is the highest building in New York City?");
diff --git a/dotnet/src/Connectors/Connectors.Memory.AzureCosmosDBMongoDB/AzureCosmosDBMongoDBConfig.cs b/dotnet/src/Connectors/Connectors.Memory.AzureCosmosDBMongoDB/AzureCosmosDBMongoDBConfig.cs
index c63779fc1379..4e23ba6f4c76 100644
--- a/dotnet/src/Connectors/Connectors.Memory.AzureCosmosDBMongoDB/AzureCosmosDBMongoDBConfig.cs
+++ b/dotnet/src/Connectors/Connectors.Memory.AzureCosmosDBMongoDB/AzureCosmosDBMongoDBConfig.cs
@@ -5,82 +5,73 @@
namespace Microsoft.SemanticKernel.Connectors.AzureCosmosDBMongoDB;
///
-/// Get more details about Azure Cosmos Mongo vCore and these configs https://learn.microsoft.com/azure/cosmos-db/mongodb/vcore/vector-search
+/// Azure Cosmos Mongo vCore configuration.
+/// More information here: https://learn.microsoft.com/azure/cosmos-db/mongodb/vcore/vector-search.
///
-public class AzureCosmosDBMongoDBConfig
+///
+/// Initialize the with default values.
+///
+public class AzureCosmosDBMongoDBConfig(int dimensions)
{
+ private const string DefaultIndexName = "default_index";
+
///
/// Application name for the client for tracking and logging
///
- public string ApplicationName { get; set; }
+ public string ApplicationName { get; set; } = HttpHeaderConstant.Values.UserAgent;
///
- /// Index name for the Mongo vCore DB
+ /// Index name for the Mongo vCore DB. Default is "default_index".
///
- public string IndexName { get; set; }
+ public string IndexName { get; set; } = DefaultIndexName;
///
- /// Kind: Type of vector index to create.
+ /// Type of vector index to create.
/// Possible options are:
- /// - vector-ivf
+ /// - vector-ivf (default)
/// - vector-hnsw: available as a preview feature only,
/// to enable visit https://learn.microsoft.com/azure/azure-resource-manager/management/preview-features
///
- public AzureCosmosDBVectorSearchType Kind { get; set; }
+ public AzureCosmosDBVectorSearchType Kind { get; set; } = AzureCosmosDBVectorSearchType.VectorIVF;
///
- /// NumLists: This integer is the number of clusters that the inverted file (IVF) index uses to group the vector data.
+ /// This integer is the number of clusters that the inverted file (IVF) index uses to group the vector data. Default is 1.
/// We recommend that numLists is set to documentCount/1000 for up to 1 million documents and to sqrt(documentCount)
/// for more than 1 million documents. Using a numLists value of 1 is akin to performing brute-force search, which has
/// limited performance.
///
- public int NumLists { get; set; }
+ public int NumLists { get; set; } = 1;
///
/// Number of dimensions for vector similarity. The maximum number of supported dimensions is 2000.
///
- public int Dimensions { get; set; }
+ public int Dimensions { get; set; } = dimensions;
///
- /// Similarity: Similarity metric to use with the IVF index.
+ /// Similarity metric to use with the IVF index.
/// Possible options are:
- /// - COS (cosine distance),
+ /// - COS (cosine distance, default),
/// - L2 (Euclidean distance), and
/// - IP (inner product).
///
- public AzureCosmosDBSimilarityType Similarity { get; set; }
+ public AzureCosmosDBSimilarityType Similarity { get; set; } = AzureCosmosDBSimilarityType.Cosine;
///
- /// NumberOfConnections: The max number of connections per layer (16 by default, minimum value is 2, maximum value is
+ /// The max number of connections per layer (16 by default, minimum value is 2, maximum value is
/// 100). Higher m is suitable for datasets with high dimensionality and/or high accuracy requirements.
///
- public int NumberOfConnections { get; set; }
+ public int NumberOfConnections { get; set; } = 16;
///
- /// EfConstruction: the size of the dynamic candidate list for constructing the graph (64 by default, minimum value is 4,
+ /// The size of the dynamic candidate list for constructing the graph (64 by default, minimum value is 4,
/// maximum value is 1000). Higher ef_construction will result in better index quality and higher accuracy, but it will
/// also increase the time required to build the index. EfConstruction has to be at least 2 * m
///
- public int EfConstruction { get; set; }
+ public int EfConstruction { get; set; } = 64;
///
- /// EfSearch: The size of the dynamic candidate list for search (40 by default). A higher value provides better recall at
+ /// The size of the dynamic candidate list for search (40 by default). A higher value provides better recall at
/// the cost of speed.
///
- public int EfSearch { get; set; }
-
- ///
- /// Initialize the AzureCosmosDBMongoDBConfig with default values
- ///
- public AzureCosmosDBMongoDBConfig()
- {
- this.ApplicationName = HttpHeaderConstant.Values.UserAgent;
- this.IndexName = "default_index";
- this.Kind = AzureCosmosDBVectorSearchType.VectorHNSW;
- this.NumLists = 1;
- this.Similarity = AzureCosmosDBSimilarityType.Cosine;
- this.NumberOfConnections = 16;
- this.EfConstruction = 64;
- this.EfSearch = 40;
- }
+ public int EfSearch { get; set; } = 40;
}
diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTests.cs b/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTests.cs
index f7ab11c84372..080c486ddcf9 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTests.cs
@@ -30,7 +30,6 @@ public async Task ItCanCreateGetCheckAndDeleteCollectionAsync()
var collectionName = this._fixture.CollectionName;
var memoryStore = this._fixture.MemoryStore;
- await memoryStore.CreateCollectionAsync(collectionName);
var collectionNames = memoryStore.GetCollectionsAsync();
Assert.True(await collectionNames.ContainsAsync(collectionName));
diff --git a/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTestsFixture.cs b/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTestsFixture.cs
index 0608af1d07d9..1074765559a8 100644
--- a/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTestsFixture.cs
+++ b/dotnet/src/IntegrationTests/Connectors/Memory/AzureCosmosDBMongoDB/AzureCosmosDBMongoDBMemoryStoreTestsFixture.cs
@@ -35,12 +35,14 @@ public AzureCosmosDBMongoDBMemoryStoreTestsFixture()
this.MemoryStore = new AzureCosmosDBMongoDBMemoryStore(
connectionString,
this.DatabaseName,
- new AzureCosmosDBMongoDBConfig()
+ new AzureCosmosDBMongoDBConfig(dimensions: 3)
);
}
public async Task InitializeAsync()
{
+ await this.MemoryStore.CreateCollectionAsync(this.CollectionName);
+
await this
.MemoryStore.UpsertBatchAsync(this.CollectionName, DataHelper.VectorSearchTestRecords)
.ToListAsync();