{"record":{"id":"9c21ce8f4ace7334","repo":"microsoft/semantic-kernel","slug":"search-type-search-type-is-not-supported","errorCode":null,"errorMessage":"Search type '{search_type}' is not supported.","messagePattern":"Search type '(.+?)' is not supported\\.","errorType":"exception","errorClass":"VectorStoreModelException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":843,"sourceCode":"        if vector_field.distance_function not in DISTANCE_FUNCTION_MAP_NOSQL:\n            raise VectorStoreModelException(\n                f\"Distance function '{vector_field.distance_function}' is not supported by Azure Cosmos DB NoSQL.\"\n            )\n        # Cosmos DB VectorDistance function only accepts 2 parameters: field and vector\n        # Distance function is configured in the vector index, not in the query\n        if search_type == SearchType.VECTOR:\n            distance_clause = f\"VectorDistance(c.{vector_field_name}, @vector)\"\n        elif search_type == SearchType.KEYWORD_HYBRID:\n            # Hybrid search: requires both a vector and keywords\n            params.append({\"name\": \"@keywords\", \"value\": values})\n            text_field = options.additional_property_name\n            if not text_field:\n                raise VectorStoreModelException(\"Hybrid search requires 'keyword_field_name' in options.\")\n            distance_clause = (\n                f\"RRF(VectorDistance(c.{vector_field_name}, @vector), FullTextScore(c.{text_field}, @keywords))\"\n            )\n        else:\n            raise VectorStoreModelException(f\"Search type '{search_type}' is not supported.\")\n        query = (\n            f\"SELECT TOP @top {select_clause}, \"  # nosec: B608\n            f\"{distance_clause} as {NOSQL_SCORE_PROPERTY_NAME} \"  # nosec: B608\n            \"FROM c \"\n            f\"{where_clauses}\"  # nosec: B608\n            f\"ORDER BY {distance_clause}\"  # nosec: B608\n        )\n\n        container_proxy = await self._get_container_proxy(self.collection_name, **kwargs)\n        try:\n            results = container_proxy.query_items(query, parameters=params)\n        except Exception as exc:\n            raise VectorSearchExecutionException(\"Failed to search items.\") from exc\n        return KernelSearchResults(\n            results=self._get_vector_search_results_from_results(results, options),\n            total_count=None,\n        )\n","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L825-L861","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nresults = await store.search(values, VectorSearchOptions(top=5))  # search_type resolved to unsupported value\n// after\nif search_type not in (SearchType.VECTOR, SearchType.KEYWORD_HYBRID):\n    raise ValueError(\"Cosmos NoSQL only supports VECTOR and KEYWORD_HYBRID\")\nresults = await store.search(values, VectorSearchOptions(top=5))\n","handlingStrategy":"validation","validationCode":"from semantic_kernel.data import SearchType\nSUPPORTED = {SearchType.VECTOR, SearchType.KEYWORD_HYBRID}\nif search_type not in SUPPORTED:\n    raise ValueError(f\"Unsupported search_type for Cosmos NoSQL: {search_type}\")","typeGuard":"def is_supported_cosmos_search(st: SearchType) -> bool:\n    return st in (SearchType.VECTOR, SearchType.KEYWORD_HYBRID)","tryCatchPattern":null,"preventionTips":["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."],"tags":["azure-cosmos-db","vector-search","search-type","configuration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}