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
2 changes: 1 addition & 1 deletion python/semantic_kernel/connectors/azure_cosmos_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def _get_index_definitions(self, **kwargs: Any) -> dict[str, Any]:
f"Distance function '{field.distance_function}' is not supported by Azure Cosmos DB for MongoDB."
)
index_name = f"{field.storage_name or field.name}_"
index_kind = DISTANCE_FUNCTION_MAP_MONGODB[field.distance_function]
index_kind = INDEX_KIND_MAP_MONGODB[field.index_kind]
index: dict[str, Any] = {
"name": index_name,
FieldTypes.KEY: {field.storage_name or field.name: "cosmosSearch"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ async def test_ensure_collection_exists_calls_database_methods(definition) -> No
)

# Act
await collection.ensure_collection_exists(customArg="customValue")
await collection.ensure_collection_exists(customArg="customValue", m=16, efConstruction=64)

# Assert
mock_database.create_collection.assert_awaited_once_with("test_collection", customArg="customValue")
mock_database.create_collection.assert_awaited_once_with("test_collection", customArg="customValue", m=16, efConstruction=64)
mock_database.command.assert_awaited()
command_args = mock_database.command.call_args.kwargs["command"]

Expand All @@ -98,9 +98,11 @@ async def test_ensure_collection_exists_calls_database_methods(definition) -> No
# Check the vector field index creation
assert command_args["indexes"][1]["name"] == "vector_"
assert command_args["indexes"][1]["key"] == {"vector": "cosmosSearch"}
assert command_args["indexes"][1]["cosmosSearchOptions"]["kind"] == "COS"
assert command_args["indexes"][1]["cosmosSearchOptions"]["similarity"] is not None
assert command_args["indexes"][1]["cosmosSearchOptions"]["kind"] == "vector-hnsw"
assert command_args["indexes"][1]["cosmosSearchOptions"]["similarity"] == "COS"
assert command_args["indexes"][1]["cosmosSearchOptions"]["dimensions"] == 5
Comment on lines +101 to 103
assert command_args["indexes"][1]["cosmosSearchOptions"]["m"] == 16
assert command_args["indexes"][1]["cosmosSearchOptions"]["efConstruction"] == 64


async def test_context_manager_calls_aconnect_and_close_when_managed(mock_model) -> None:
Expand Down
Loading