{"record":{"id":"4c6b8b5585f06e71","repo":"microsoft/semantic-kernel","slug":"index-kind-field-index-kind-is-not-supported-b-4c6b8b","errorCode":null,"errorMessage":"Index kind '{field.index_kind}' is not supported by Azure Cosmos DB for MongoDB.","messagePattern":"Index kind '(.+?)' is not supported by Azure Cosmos DB for MongoDB\\.","errorType":"exception","errorClass":"VectorStoreModelException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":394,"sourceCode":"                for more information.\n                Other kwargs are passed to the create_collection method.\n        \"\"\"\n        await self._get_database().create_collection(self.collection_name, **kwargs)\n        await self._get_database().command(command=self._get_index_definitions(**kwargs))\n\n    def _get_index_definitions(self, **kwargs: Any) -> dict[str, Any]:\n        \"\"\"Creates index definitions for the collection.\"\"\"\n        indexes = [\n            {\n                \"name\": f\"{field.storage_name or field.name}_\",\n                FieldTypes.KEY: {field.storage_name or field.name: 1},\n            }\n            for field in self.definition.data_fields\n            if field.is_indexed or field.is_full_text_indexed\n        ]\n        for field in self.definition.vector_fields:\n            if field.index_kind not in INDEX_KIND_MAP_MONGODB:\n                raise VectorStoreModelException(\n                    f\"Index kind '{field.index_kind}' is not supported by Azure Cosmos DB for MongoDB.\"\n                )\n            if field.distance_function not in DISTANCE_FUNCTION_MAP_MONGODB:\n                raise VectorStoreModelException(\n                    f\"Distance function '{field.distance_function}' is not supported by Azure Cosmos DB for MongoDB.\"\n                )\n            index_name = f\"{field.storage_name or field.name}_\"\n            index_kind = DISTANCE_FUNCTION_MAP_MONGODB[field.distance_function]\n            index: dict[str, Any] = {\n                \"name\": index_name,\n                FieldTypes.KEY: {field.storage_name or field.name: \"cosmosSearch\"},\n                \"cosmosSearchOptions\": {\n                    \"kind\": index_kind,\n                    \"similarity\": DISTANCE_FUNCTION_MAP_MONGODB[field.distance_function],\n                    \"dimensions\": field.dimensions,\n                },\n            }\n            match index_kind:","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L376-L412","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nVectorStoreRecordVectorField(name=\"embedding\", dimensions=1536, index_kind=IndexKind.FLAT)\n// after\nVectorStoreRecordVectorField(name=\"embedding\", dimensions=1536, index_kind=IndexKind.HNSW)","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.azure_cosmos_db import INDEX_KIND_MAP_MONGODB\n\nbad = [f for f in definition.vector_fields if f.index_kind not in INDEX_KIND_MAP_MONGODB]\nif bad:\n    raise ValueError(f\"Unsupported index kinds: {[(f.name, f.index_kind) for f in bad]}\")\n","typeGuard":"def is_supported_mongodb_index_kind(k: IndexKind) -> bool:\n    return k in INDEX_KIND_MAP_MONGODB\n","tryCatchPattern":null,"preventionTips":["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."],"tags":["azure-cosmos-db","mongodb","vector-store","data-model","indexing"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}