microsoft/semantic-kernel · error · VectorStoreModelException
Index kind '{field.index_kind}' is not supported by Azure Co
Error message
Index kind '{field.index_kind}' is not supported by Azure Cosmos DB for MongoDB. What it means
When CosmosMongoCollection builds index definitions, each vector field's index_kind must be one Cosmos DB for MongoDB supports (IVF_FLAT, HNSW, DISK_ANN, or DEFAULT). Any other IndexKind value raises VectorStoreModelException at index-definition build time, which typically runs when the collection is created or its indexes are materialized.
Source
Thrown at python/semantic_kernel/connectors/azure_cosmos_db.py:394
for more information.
Other kwargs are passed to the create_collection method.
"""
await self._get_database().create_collection(self.collection_name, **kwargs)
await self._get_database().command(command=self._get_index_definitions(**kwargs))
def _get_index_definitions(self, **kwargs: Any) -> dict[str, Any]:
"""Creates index definitions for the collection."""
indexes = [
{
"name": f"{field.storage_name or field.name}_",
FieldTypes.KEY: {field.storage_name or field.name: 1},
}
for field in self.definition.data_fields
if field.is_indexed or field.is_full_text_indexed
]
for field in self.definition.vector_fields:
if field.index_kind not in INDEX_KIND_MAP_MONGODB:
raise VectorStoreModelException(
f"Index kind '{field.index_kind}' is not supported by Azure Cosmos DB for MongoDB."
)
if field.distance_function not in DISTANCE_FUNCTION_MAP_MONGODB:
raise VectorStoreModelException(
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: dict[str, Any] = {
"name": index_name,
FieldTypes.KEY: {field.storage_name or field.name: "cosmosSearch"},
"cosmosSearchOptions": {
"kind": index_kind,
"similarity": DISTANCE_FUNCTION_MAP_MONGODB[field.distance_function],
"dimensions": field.dimensions,
},
}
match index_kind:View on GitHub (pinned to c028a0c7dc)
Solutions
- Set the vector field's index_kind to IndexKind.IVF_FLAT, IndexKind.HNSW, IndexKind.DISK_ANN, or IndexKind.DEFAULT.
- Keep separate VectorStoreCollectionDefinitions for NoSQL vs MongoDB collections if metrics differ.
- Verify the IndexKind enum value spelling matches a supported constant.
Example fix
// before VectorStoreRecordVectorField(name="embedding", dimensions=1536, index_kind=IndexKind.FLAT) // after VectorStoreRecordVectorField(name="embedding", dimensions=1536, index_kind=IndexKind.HNSW)
Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.connectors.azure_cosmos_db import INDEX_KIND_MAP_MONGODB
bad = [f for f in definition.vector_fields if f.index_kind not in INDEX_KIND_MAP_MONGODB]
if bad:
raise ValueError(f"Unsupported index kinds: {[(f.name, f.index_kind) for f in bad]}")
Type guard
def is_supported_mongodb_index_kind(k: IndexKind) -> bool:
return k in INDEX_KIND_MAP_MONGODB
Prevention
- Keep MongoDB and NoSQL data models separate; do not share when index kinds differ.
- Document which IndexKind each target store supports in your project.
- Unit-test model definitions against each connector's support map.
When it happens
Trigger: Raised in CosmosMongoCollection._get_index_definitions when a vector field's field.index_kind not in INDEX_KIND_MAP_MONGODB. Triggered when the data model declares a vector field with IndexKind.FLAT, IndexKind.QUANTIZED_FLAT, or another NoSQL-only / unsupported value.
Common situations: Reusing a NoSQL-oriented data model (which uses FLAT/QUANTIZED_FLAT/DISK_ANN) against a MongoDB collection. Copying an index_kind from a tutorial for a different store. Mismatching the index kind between two collections sharing one definition.
Related errors
- Distance function '{field.distance_function}' is not support
- Vector field '{options.vector_property_name}' not found in t
- Distance function '{field.distance_function}' is not support
- Vector property type '{field.type_}' is not supported by Azu
- Failed to search the collection.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/4c6b8b5585f06e71.
Report an issue: GitHub.