microsoft/semantic-kernel · error · VectorStoreModelException
Search type '{search_type}' is not supported.
Error message
Search type '{search_type}' is not supported. What it means
The Cosmos DB NoSQL store only implements two search modes: VECTOR (pure VectorDistance) and KEYWORD_HYBRID (RRF of VectorDistance and FullTextScore). Any other SearchType enum value falls through to an else branch and raises a VectorStoreModelException. The connector simply has no code path for additional search types, so the request is rejected before any query is built.
Source
Thrown at python/semantic_kernel/connectors/azure_cosmos_db.py:843
if vector_field.distance_function not in DISTANCE_FUNCTION_MAP_NOSQL:
raise VectorStoreModelException(
f"Distance function '{vector_field.distance_function}' is not supported by Azure Cosmos DB NoSQL."
)
# Cosmos DB VectorDistance function only accepts 2 parameters: field and vector
# Distance function is configured in the vector index, not in the query
if search_type == SearchType.VECTOR:
distance_clause = f"VectorDistance(c.{vector_field_name}, @vector)"
elif search_type == SearchType.KEYWORD_HYBRID:
# Hybrid search: requires both a vector and keywords
params.append({"name": "@keywords", "value": values})
text_field = options.additional_property_name
if not text_field:
raise VectorStoreModelException("Hybrid search requires 'keyword_field_name' in options.")
distance_clause = (
f"RRF(VectorDistance(c.{vector_field_name}, @vector), FullTextScore(c.{text_field}, @keywords))"
)
else:
raise VectorStoreModelException(f"Search type '{search_type}' is not supported.")
query = (
f"SELECT TOP @top {select_clause}, " # nosec: B608
f"{distance_clause} as {NOSQL_SCORE_PROPERTY_NAME} " # nosec: B608
"FROM c "
f"{where_clauses}" # nosec: B608
f"ORDER BY {distance_clause}" # nosec: B608
)
container_proxy = await self._get_container_proxy(self.collection_name, **kwargs)
try:
results = container_proxy.query_items(query, parameters=params)
except Exception as exc:
raise VectorSearchExecutionException("Failed to search items.") from exc
return KernelSearchResults(
results=self._get_vector_search_results_from_results(results, options),
total_count=None,
)
View on GitHub (pinned to c028a0c7dc)
Solutions
- Restrict the SearchType you pass to SearchType.VECTOR or SearchType.KEYWORD_HYBRID when using the Cosmos NoSQL store.
- If you need text-only keyword search, that mode is not supported by this connector; switch to a connector that implements it or run a manual Cosmos SQL query.
- Guard dynamic search_type values before calling search so unsupported types are rejected with your own validation rather than the library exception.
Example fix
// before
results = await store.search(values, VectorSearchOptions(top=5)) # search_type resolved to unsupported value
// after
if search_type not in (SearchType.VECTOR, SearchType.KEYWORD_HYBRID):
raise ValueError("Cosmos NoSQL only supports VECTOR and KEYWORD_HYBRID")
results = await store.search(values, VectorSearchOptions(top=5))
Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.data import SearchType
SUPPORTED = {SearchType.VECTOR, SearchType.KEYWORD_HYBRID}
if search_type not in SUPPORTED:
raise ValueError(f"Unsupported search_type for Cosmos NoSQL: {search_type}") Type guard
def is_supported_cosmos_search(st: SearchType) -> bool:
return st in (SearchType.VECTOR, SearchType.KEYWORD_HYBRID) Prevention
- Restrict dynamic search_type to the two Cosmos-supported values before calling search.
- Do not port search-type logic from other connectors without checking Cosmos support.
When it happens
Trigger: Calling _inner_search / the public search API with a SearchType value that is neither SearchType.VECTOR nor SearchType.KEYWORD_HYBRID (e.g. a pure keyword/text-only search, or a future enum member the installed version does not handle).
Common situations: A caller passes search_type based on dynamic/user input without restricting it to the two supported values, or code written against another connector (which supports more SearchType members) is pointed at the Cosmos NoSQL store.
Related errors
- Hybrid search requires 'keyword_field_name' in options.
- Distance function '{field.distance_function}' is not support
- The collection name is required, can be passed directly or t
- Failed to create Azure CosmosDB for MongoDB settings.
- The name of the Azure Cosmos DB NoSQL database is missing.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/9c21ce8f4ace7334.
Report an issue: GitHub.