microsoft/semantic-kernel · error · VectorStoreOperationException
Vector is required for search.
Error message
Vector is required for search.
What it means
Raised by MongoDBAtlasCollection._inner_search (VectorStoreOperationException) as the fallback when search_type is neither VECTOR nor KEYWORD_HYBRID — the only two modes this connector implements. Despite the message ('Vector is required for search.'), the real cause is an unsupported search type (e.g. a text-only KEYWORD search or a future/new SearchType value).
Source
Thrown at python/semantic_kernel/connectors/mongodb.py:354
@override
async def ensure_collection_deleted(self, **kwargs) -> None:
await self._get_database().drop_collection(self.collection_name, **kwargs)
@override
async def _inner_search(
self,
search_type: SearchType,
options: VectorSearchOptions,
values: Any | None = None,
vector: Sequence[float | int] | None = None,
**kwargs: Any,
) -> KernelSearchResults[VectorSearchResult[TModel]]:
if search_type == SearchType.VECTOR:
return await self._inner_vector_search(options, values, vector, **kwargs)
if search_type == SearchType.KEYWORD_HYBRID:
return await self._inner_keyword_hybrid_search(options, values, vector, **kwargs)
raise VectorStoreOperationException("Vector is required for search.")
async def _inner_vector_search(
self,
options: VectorSearchOptions,
values: Any | None = None,
vector: Sequence[float | int] | None = None,
**kwargs: Any,
) -> KernelSearchResults[VectorSearchResult[TModel]]:
collection = self._get_collection()
vector_field = self.definition.try_get_vector_field(options.vector_property_name)
if not vector_field:
raise VectorStoreModelException(
f"Vector field '{options.vector_property_name}' not found in the data model definition."
)
if not vector:
vector = await self._generate_vector_from_values(values, options)
vector_search_query: dict[str, Any] = {
"limit": options.top + options.skip,View on GitHub (pinned to c028a0c7dc)
Solutions
- Use SearchType.VECTOR (pure vector) or SearchType.KEYWORD_HYBRID for this collection.
- For text-only keyword search, use a dedicated text-search collection/store instead of the Atlas vector collection.
- Validate search_type against {VECTOR, KEYWORD_HYBRID} before calling search.
Example fix
// before await collection.search(search_type=SearchType.KEYWORD, vector=emb) // after await collection.search(search_type=SearchType.VECTOR, vector=emb)
Defensive patterns
Strategy: validation
Validate before calling
from semantic_kernel.data.vector import SearchType
allowed = {SearchType.VECTOR, SearchType.KEYWORD_HYBRID}
if search_type not in allowed:
raise ValueError(f'MongoDBAtlasCollection supports only {allowed}')
await collection.search(search_type=search_type, vector=emb) Type guard
from semantic_kernel.data.vector import SearchType
def is_supported_search(st) -> bool:
return st in {SearchType.VECTOR, SearchType.KEYWORD_HYBRID} Try / catch
from semantic_kernel.exceptions import VectorStoreOperationException
try:
await collection.search(search_type=search_type, vector=emb)
except VectorStoreOperationException as e:
if 'required for search' in str(e):
await collection.search(search_type=SearchType.VECTOR, vector=emb)
else:
raise Prevention
- Use only VECTOR or KEYWORD_HYBRID search types with MongoDBAtlasCollection.
- For text-only keyword search, use a dedicated text-search store.
- Validate search_type against the connector's supported set before calling.
When it happens
Trigger: Calling `collection.search(search_type=SearchType.KEYWORD, ...)` or passing a custom/raw search_type string. SearchType currently has only VECTOR and KEYWORD_HYBRID, so this is typically a new enum member or an externally-supplied value.
Common situations: Using generic cross-connector search code that passes SearchType.KEYWORD (text search); upgrading SK and using a new SearchType this connector hasn't mapped; misrouting a text-only query to the vector collection.
Related errors
- Vector field '{options.vector_property_name}' not found in t
- Failed to search the collection.
- Vector field '{options.vector_property_name}' not found in t
- Failed to search the collection.
- Index kind '{field.index_kind}' is not supported by Azure Co
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/0d67e87930345842.
Report an issue: GitHub.