Repository navigation
Commit 80161f5
authored
Python: Fix Cosmos MongoDB vector index kind set to similarity code (#14620)
Fixes #14104
`CosmosMongoCollection._get_index_definitions` set `"kind"` from
`DISTANCE_FUNCTION_MAP_MONGODB[field.distance_function]`
(`"COS"`/`"IP"`/`"L2"`) instead of
`INDEX_KIND_MAP_MONGODB[field.index_kind]`
(`"vector-ivf"`/`"vector-hnsw"`/`"vector-diskann"`). This produced
invalid `createIndexes` calls, and the `match index_kind:` block could
never hit a `vector-*` case, silently dropping HNSW/IVF/DiskANN tuning
options (`m`, `efConstruction`, …).
One-line fix: `index_kind = INDEX_KIND_MAP_MONGODB[field.index_kind]`.
Also corrected the existing test
`test_ensure_collection_exists_calls_database_methods`, which had
encoded the bug (`kind == "COS"`).
Tests: new `test_get_index_definitions_uses_index_kind_for_kind` (fails
before / passes after); cosmos + redis test files 34 passed; wider
`tests/unit/connectors/memory/` 163 passed; ruff clean.
*AI assistance disclosure: prepared with AI assistance; verified
locally.*1 parent b11d98b commit 80161f5
2 files changed
Lines changed: 49 additions & 3 deletions
File tree
- python
- semantic_kernel/connectors
- tests/unit/connectors/memory/azure_cosmos_db
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
403 | | - | |
| 403 | + | |
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
105 | 108 | | |
| |||
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
0 commit comments