{"record":{"id":"befbb968fd68ad4f","repo":"microsoft/semantic-kernel","slug":"index-kind-field-index-kind-is-not-supported","errorCode":null,"errorMessage":"Index kind {field.index_kind} is not supported.","messagePattern":"Index kind (.+?) is not supported\\.","errorType":"exception","errorClass":"VectorStoreInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/faiss.py","lineNumber":48,"sourceCode":"    from typing_extensions import override  # pragma: no cover\n\nlogger = logging.getLogger(__name__)\n\nDISTANCE_FUNCTION_MAP: Final[dict[DistanceFunction, type[faiss.Index]]] = {\n    DistanceFunction.EUCLIDEAN_SQUARED_DISTANCE: faiss.IndexFlatL2,\n    DistanceFunction.DOT_PROD: faiss.IndexFlatIP,\n    DistanceFunction.DEFAULT: faiss.IndexFlatL2,\n}\nINDEX_KIND_MAP: Final[dict[IndexKind, bool]] = {\n    IndexKind.FLAT: True,\n    IndexKind.DEFAULT: True,\n}\n\n\ndef _create_index(field: VectorStoreField) -> faiss.Index:\n    \"\"\"Create a Faiss index.\"\"\"\n    if field.index_kind not in INDEX_KIND_MAP:\n        raise VectorStoreInitializationException(f\"Index kind {field.index_kind} is not supported.\")\n    if field.distance_function not in DISTANCE_FUNCTION_MAP:\n        raise VectorStoreInitializationException(f\"Distance function {field.distance_function} is not supported.\")\n    match field.index_kind:\n        case IndexKind.FLAT | IndexKind.DEFAULT:\n            match field.distance_function:\n                case DistanceFunction.EUCLIDEAN_SQUARED_DISTANCE | DistanceFunction.DEFAULT:\n                    return faiss.IndexFlatL2(field.dimensions)\n                case DistanceFunction.DOT_PROD:\n                    return faiss.IndexFlatIP(field.dimensions)\n                case _:\n                    raise VectorStoreInitializationException(\n                        f\"Distance function {field.distance_function} is \"\n                        f\"not supported for index kind {field.index_kind}.\"\n                    )\n        case _:\n            raise VectorStoreInitializationException(f\"Index with {field.index_kind} is not supported.\")\n\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/faiss.py#L30-L66","documentation":"A VectorStoreInitializationException raised by _create_index() in the Faiss connector when a vector field's index_kind is not in INDEX_KIND_MAP (faiss.py:44-47), which only contains IndexKind.FLAT and IndexKind.DEFAULT. Faiss collections in this connector support only flat (brute-force) indexes via this path; other index kinds (HNSW, IVF, etc.) are rejected at index creation.","triggerScenarios":"Defining a VectorStoreRecordVectorField with index_kind=IndexKind.HNSW (or IVF/any non-FLAT) and constructing a FaissCollection that auto-creates an index for that field (i.e. not supplying a pre-built faiss.Index).","commonSituations":"Porting a Chroma model (HNSW) to Faiss without changing index_kind; expecting the connector to build an approximate-search index automatically.","solutions":["Set the vector field's index_kind to IndexKind.FLAT (or IndexKind.DEFAULT) so _create_index can build a faiss.IndexFlatL2/IndexFlatIP.","If you need an approximate index (IVF/HNSW/IVFPQ), construct it yourself with faiss and pass it via the 'index'/'indexes' parameter of FaissCollection instead of relying on auto-creation."],"exampleFix":"// before\nVectorStoreRecordVectorField(name=\"embedding\", index_kind=IndexKind.HNSW, dimensions=1536)\n// after\nVectorStoreRecordVectorField(name=\"embedding\", index_kind=IndexKind.FLAT, dimensions=1536)","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.faiss import INDEX_KIND_MAP\nassert all(f.index_kind in INDEX_KIND_MAP for f in definition.vector_fields), (\n    f\"Faiss auto-index supports only: {[k.value for k in INDEX_KIND_MAP]}\"\n)","typeGuard":"from semantic_kernel.data.vector import IndexKind\nfrom semantic_kernel.connectors.faiss import INDEX_KIND_MAP\n\ndef is_faiss_auto_index_kind(kind: IndexKind) -> bool:\n    return kind in INDEX_KIND_MAP","tryCatchPattern":"from semantic_kernel.exceptions import VectorStoreInitializationException\ntry:\n    FaissCollection(record_type=Doc)\nexcept VectorStoreInitializationException as e:\n    if \"Index kind\" in str(e):\n        # set index_kind=IndexKind.FLAT or supply a pre-built faiss.Index\n        ...","preventionTips":["Use IndexKind.FLAT for Faiss auto-created indexes.","For approximate indexes, build and pass a faiss.Index explicitly."],"tags":["faiss","vector-store","configuration","index-kind"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}