microsoft/semantic-kernel · error · VectorStoreInitializationException

Index kind {field.index_kind} is not supported.

Error message

Index kind {field.index_kind} is not supported.

What it means

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.

Source

Thrown at python/semantic_kernel/connectors/faiss.py:48

    from typing_extensions import override  # pragma: no cover

logger = logging.getLogger(__name__)

DISTANCE_FUNCTION_MAP: Final[dict[DistanceFunction, type[faiss.Index]]] = {
    DistanceFunction.EUCLIDEAN_SQUARED_DISTANCE: faiss.IndexFlatL2,
    DistanceFunction.DOT_PROD: faiss.IndexFlatIP,
    DistanceFunction.DEFAULT: faiss.IndexFlatL2,
}
INDEX_KIND_MAP: Final[dict[IndexKind, bool]] = {
    IndexKind.FLAT: True,
    IndexKind.DEFAULT: True,
}


def _create_index(field: VectorStoreField) -> faiss.Index:
    """Create a Faiss index."""
    if field.index_kind not in INDEX_KIND_MAP:
        raise VectorStoreInitializationException(f"Index kind {field.index_kind} is not supported.")
    if field.distance_function not in DISTANCE_FUNCTION_MAP:
        raise VectorStoreInitializationException(f"Distance function {field.distance_function} is not supported.")
    match field.index_kind:
        case IndexKind.FLAT | IndexKind.DEFAULT:
            match field.distance_function:
                case DistanceFunction.EUCLIDEAN_SQUARED_DISTANCE | DistanceFunction.DEFAULT:
                    return faiss.IndexFlatL2(field.dimensions)
                case DistanceFunction.DOT_PROD:
                    return faiss.IndexFlatIP(field.dimensions)
                case _:
                    raise VectorStoreInitializationException(
                        f"Distance function {field.distance_function} is "
                        f"not supported for index kind {field.index_kind}."
                    )
        case _:
            raise VectorStoreInitializationException(f"Index with {field.index_kind} is not supported.")

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Set the vector field's index_kind to IndexKind.FLAT (or IndexKind.DEFAULT) so _create_index can build a faiss.IndexFlatL2/IndexFlatIP.
  2. 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.

Example fix

// before
VectorStoreRecordVectorField(name="embedding", index_kind=IndexKind.HNSW, dimensions=1536)
// after
VectorStoreRecordVectorField(name="embedding", index_kind=IndexKind.FLAT, dimensions=1536)
Defensive patterns

Strategy: validation

Validate before calling

from semantic_kernel.connectors.faiss import INDEX_KIND_MAP
assert all(f.index_kind in INDEX_KIND_MAP for f in definition.vector_fields), (
    f"Faiss auto-index supports only: {[k.value for k in INDEX_KIND_MAP]}"
)

Type guard

from semantic_kernel.data.vector import IndexKind
from semantic_kernel.connectors.faiss import INDEX_KIND_MAP

def is_faiss_auto_index_kind(kind: IndexKind) -> bool:
    return kind in INDEX_KIND_MAP

Try / catch

from semantic_kernel.exceptions import VectorStoreInitializationException
try:
    FaissCollection(record_type=Doc)
except VectorStoreInitializationException as e:
    if "Index kind" in str(e):
        # set index_kind=IndexKind.FLAT or supply a pre-built faiss.Index
        ...

Prevention

When it happens

Trigger: 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).

Common situations: Porting a Chroma model (HNSW) to Faiss without changing index_kind; expecting the connector to build an approximate-search index automatically.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/befbb968fd68ad4f. Report an issue: GitHub.