{"record":{"id":"4b7d9ff5cde1ec8f","repo":"microsoft/semantic-kernel","slug":"index-kind-field-index-kind-is-not-supported-b","errorCode":null,"errorMessage":"Index kind '{field.index_kind}' is not supported by Azure Cosmos DB NoSQL container.","messagePattern":"Index kind '(.+?)' is not supported by Azure Cosmos DB NoSQL container\\.","errorType":"exception","errorClass":"VectorStoreModelException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":145,"sourceCode":"            {\n                \"path\": \"/*\",\n            }\n        ],\n        \"excludedPaths\": [\n            {\n                \"path\": '/\"_etag\"/?',\n            }\n        ],\n        \"vectorIndexes\": [],\n    }\n\n    for field in definition.fields:\n        if field.field_type == FieldTypes.DATA and (not field.is_full_text_indexed and not field.is_indexed):\n            indexing_policy[\"excludedPaths\"].append({\"path\": f'/\"{field.storage_name or field.name}\"/*'})\n\n        if field.field_type == FieldTypes.VECTOR:\n            if field.index_kind not in INDEX_KIND_MAP_NOSQL:\n                raise VectorStoreModelException(\n                    f\"Index kind '{field.index_kind}' is not supported by Azure Cosmos DB NoSQL container.\"\n                )\n            indexing_policy[\"vectorIndexes\"].append({\n                \"path\": f'/\"{field.storage_name or field.name}\"',\n                \"type\": INDEX_KIND_MAP_NOSQL[field.index_kind],\n            })\n            # Exclude the vector field from the index for performance optimization.\n            indexing_policy[\"excludedPaths\"].append({\"path\": f'/\"{field.storage_name or field.name}\"/*'})\n\n    return indexing_policy\n\n\ndef _create_default_vector_embedding_policy(definition: VectorStoreCollectionDefinition) -> dict[str, Any]:\n    \"\"\"Creates a default vector embedding policy for the Azure Cosmos DB NoSQL container.\n\n    A default vector embedding policy is created based on the data model definition.\n\n    Args:","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L127-L163","documentation":"Raised by _create_default_indexing_policy_nosql when a VECTOR field's index_kind is not a key in INDEX_KIND_MAP_NOSQL. Azure Cosmos DB NoSQL supports only FLAT, QUANTIZED_FLAT, DISK_ANN, and DEFAULT. Other IndexKind values (HNSW, IVF_FLAT, DYNAMIC) are valid for other stores but not for Cosmos NoSQL, so building the container indexing policy fails with a VectorStoreModelException during collection creation.","triggerScenarios":"Creating a Cosmos DB NoSQL collection (ensure_collection_exists) whose definition sets a vector field's index_kind to IndexKind.HNSW, IndexKind.IVF_FLAT, or IndexKind.DYNAMIC. Fires while constructing the default indexing policy from the definition, before any Azure call.","commonSituations":"Porting a model from Azure AI Search (which uses HNSW) or MongoDB Atlas (IVF_FLAT/HNSW) to Cosmos DB NoSQL without changing index_kind; using DEFAULT and assuming it maps to HNSW (it maps to FLAT in Cosmos NoSQL, which is valid, so DEFAULT itself won't trigger this).","solutions":["Set the vector field's index_kind to IndexKind.FLAT, IndexKind.QUANTIZED_FLAT, IndexKind.DISK_ANN, or IndexKind.DEFAULT for Cosmos DB NoSQL.","Use DISK_ANN for large-scale vector datasets (the Cosmos-recommended ANN option) or QUANTIZED_FLAT for smaller datasets needing compression.","Validate all vector field index_kinds against INDEX_KIND_MAP_NOSQL before creating the container."],"exampleFix":"// before\nfield(type_='float', name='embedding', index_kind=IndexKind.HNSW)\n\n// after\nfield(type_='float', name='embedding', index_kind=IndexKind.DISK_ANN)","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.azure_cosmos_db import INDEX_KIND_MAP_NOSQL\n\ndef validate_cosmos_vector_kinds(definition) -> list[str]:\n    bad = []\n    for f in definition.fields:\n        if f.field_type.value == \"vector\" and f.index_kind not in INDEX_KIND_MAP_NOSQL:\n            bad.append(f\"{f.name}: {f.index_kind}\")\n    return bad\n\nassert not validate_cosmos_vector_kinds(definition)","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import VectorStoreModelException\ntry:\n    await collection.ensure_collection_exists()\nexcept VectorStoreModelException as e:\n    if \"not supported by Azure Cosmos DB NoSQL\" in str(e):\n        # change index_kind to DISK_ANN / QUANTIZED_FLAT / FLAT / DEFAULT\n        ...\n    raise","preventionTips":["For Cosmos DB NoSQL, use FLAT, QUANTIZED_FLAT, DISK_ANN, or DEFAULT only.","Re-map index_kind when porting a definition from Azure AI Search (HNSW) or MongoDB (IVF_FLAT/HNSW).","Validate vector index_kinds against INDEX_KIND_MAP_NOSQL in a test before container creation."],"tags":["schema","vector-index","azure-cosmos-db","data-model"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}