{"record":{"id":"46cf102825dfe602","repo":"microsoft/semantic-kernel","slug":"vector-field-options-vector-property-name-not-46cf10","errorCode":null,"errorMessage":"Vector field '{options.vector_property_name}' not found in the data model definition.","messagePattern":"Vector field '(.+?)' not found in the data model definition\\.","errorType":"exception","errorClass":"VectorStoreModelException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/mongodb.py","lineNumber":366,"sourceCode":"        **kwargs: Any,\n    ) -> KernelSearchResults[VectorSearchResult[TModel]]:\n        if search_type == SearchType.VECTOR:\n            return await self._inner_vector_search(options, values, vector, **kwargs)\n        if search_type == SearchType.KEYWORD_HYBRID:\n            return await self._inner_keyword_hybrid_search(options, values, vector, **kwargs)\n        raise VectorStoreOperationException(\"Vector is required for search.\")\n\n    async def _inner_vector_search(\n        self,\n        options: VectorSearchOptions,\n        values: Any | None = None,\n        vector: Sequence[float | int] | None = None,\n        **kwargs: Any,\n    ) -> KernelSearchResults[VectorSearchResult[TModel]]:\n        collection = self._get_collection()\n        vector_field = self.definition.try_get_vector_field(options.vector_property_name)\n        if not vector_field:\n            raise VectorStoreModelException(\n                f\"Vector field '{options.vector_property_name}' not found in the data model definition.\"\n            )\n        if not vector:\n            vector = await self._generate_vector_from_values(values, options)\n        vector_search_query: dict[str, Any] = {\n            \"limit\": options.top + options.skip,\n            \"index\": self.index_name,\n            \"queryVector\": vector,\n            \"path\": vector_field.storage_name or vector_field.name,\n        }\n        if filter := self._build_filter(options.filter):\n            vector_search_query[\"filter\"] = filter if isinstance(filter, dict) else {\"$and\": filter}\n\n        projection_query: dict[str, int | dict] = {\n            field: 1\n            for field in self.definition.get_names(\n                include_vector_fields=options.include_vectors,\n                include_key_field=False,  # _id is always included","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/mongodb.py#L348-L384","documentation":"Raised by MongoDBAtlasCollection._inner_vector_search (VectorStoreModelException) when `definition.try_get_vector_field(options.vector_property_name)` returns None — i.e. the requested vector property name is not a declared vector field in the data model definition. This is a model-mapping error, not a data error: the connector cannot find where to point the $vectorSearch 'path'.","triggerScenarios":"Calling vector search with options.vector_property_name set to a name that is not annotated as a vector field; or with a model definition that has no vector field at all; or a name/storage_name mismatch. If vector_property_name is None and there is exactly one vector field it is usually auto-selected, so this fires when the name is explicitly wrong or ambiguous.","commonSituations":"Typo in vector_property_name; field annotated as a data field instead of VectorStoreRecordVectorField; using storage_name in the option instead of the property name; model definition missing the vector field decorator/annotation.","solutions":["Set options.vector_property_name to a name declared as a vector field in the record definition.","Ensure your model has a VectorStoreRecordVectorField annotation.","Leave vector_property_name unset to let the connector pick the single declared vector field."],"exampleFix":"// before\nawait collection.search(search_type=SearchType.VECTOR, options=VectorSearchOptions(vector_property_name='content'))\n// after\nawait collection.search(search_type=SearchType.VECTOR, options=VectorSearchOptions(vector_property_name='embedding'))  // 'embedding' is the annotated vector field","handlingStrategy":"validation","validationCode":"vf = collection.definition.try_get_vector_field(options.vector_property_name)\nif vf is None:\n    raise ValueError(f'{options.vector_property_name!r} is not a declared vector field')\nawait collection._inner_vector_search(options, vector=emb)","typeGuard":"def has_vector_field(definition, name: str | None) -> bool:\n    return definition.try_get_vector_field(name) is not None","tryCatchPattern":"from semantic_kernel.exceptions.vector_store_exceptions import VectorStoreModelException\ntry:\n    await collection.search(search_type=SearchType.VECTOR, vector=emb, options=options)\nexcept VectorStoreModelException as e:\n    if 'not found' in str(e):\n        options.vector_property_name = None  # let connector auto-select\n    raise","preventionTips":["Annotate exactly the vector fields you need with VectorStoreRecordVectorField.","Leave vector_property_name unset when there is a single vector field (auto-select).","Use the property name, not the storage_name, in options."],"tags":["mongodb","vector-store","data-model","search","vector-field"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}