microsoft/semantic-kernel · warning · VectorStoreInitializationException
Distance function {field.distance_function} is not supported
Error message
Distance function {field.distance_function} is not supported for index kind {field.index_kind}. What it means
A VectorStoreInitializationException raised by the inner match in _create_index() for the FLAT/DEFAULT index_kind branch when the distance_function is supported by the outer map but has no case in the inner match (the inner match only handles EUCLIDEAN_SQUARED_DISTANCE/DEFAULT -> IndexFlatL2 and DOT_PROD -> IndexFlatIP, with a '_' fallback). Because the outer DISTANCE_FUNCTION_MAP and the inner match share the same supported set, this branch is effectively a secondary guard that fires only if the two sets ever diverge.
Source
Thrown at python/semantic_kernel/connectors/faiss.py:59
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.")
class FaissCollection(InMemoryCollection[TKey, TModel], Generic[TKey, TModel]):
"""Create a Faiss collection.
The Faiss Collection builds on the InMemoryVectorCollection,
it maintains indexes and mappings for each vector field.
"""
indexes: MutableMapping[str, faiss.Index] = Field(default_factory=dict)
indexes_key_map: MutableMapping[str, MutableMapping[TKey, int]] = Field(default_factory=dict)
def __init__(View on GitHub (pinned to c028a0c7dc)
Solutions
- Check the library version / file an issue — the inner and outer distance-function maps should stay consistent.
- As a workaround, supply a pre-built faiss.Index via the 'index'/'indexes' parameter to bypass _create_index entirely.
Defensive patterns
Strategy: try-catch
Validate before calling
from semantic_kernel.connectors.faiss import DISTANCE_FUNCTION_MAP
SUPPORTED_INNER = {DistanceFunction.EUCLIDEAN_SQUARED_DISTANCE, DistanceFunction.DEFAULT, DistanceFunction.DOT_PROD}
assert set(DISTANCE_FUNCTION_MAP) == SUPPORTED_INNER, "Faiss distance maps are inconsistent; report a library bug" Try / catch
from semantic_kernel.exceptions import VectorStoreInitializationException
try:
FaissCollection(record_type=Doc)
except VectorStoreInitializationException as e:
if "not supported for index kind" in str(e):
# supply a pre-built faiss.Index to bypass _create_index
... Prevention
- Pin a known-good library version.
- When in doubt, pass a pre-built faiss.Index instead of relying on auto-creation.
When it happens
Trigger: Reachable only if a distance_function is present in DISTANCE_FUNCTION_MAP (passes the outer check at faiss.py:49-50) but lacks a case in the inner match. With the current maps these sets are identical, so it is defensive; would fire if the maps were edited inconsistently.
Common situations: Not encountered in normal usage. Could surface after a library upgrade that adds a distance function to the outer map but forgets the inner match.
Related errors
- Distance function {field.distance_function} is not supported
- Index with {field.index_kind} is not supported.
- Distance function {vector_field.distance_function} is not su
- Index kind {field.index_kind} is not supported.
- Index must be a subtype of faiss.Index
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/777145651d0370ac.
Report an issue: GitHub.