{"record":{"id":"8738d30adbedf0e9","repo":"microsoft/semantic-kernel","slug":"no-match-found","errorCode":null,"errorMessage":"No match found","messagePattern":"No match found","errorType":"exception","errorClass":"ServiceResourceNotFoundError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/postgres/postgres_memory_store.py","lineNumber":475,"sourceCode":"\n        Args:\n            collection_name: The name of the collection to get the nearest match from.\n            embedding: The embedding to find the nearest match to.\n            min_relevance_score: The minimum relevance score of the match. (default: {0.0})\n            with_embedding: Whether to include the embedding in the result. (default: {False})\n\n        Returns:\n            Tuple[MemoryRecord, float]: The record and the relevance score.\n        \"\"\"\n        results = await self.get_nearest_matches(\n            collection_name=collection_name,\n            embedding=embedding,\n            limit=1,\n            min_relevance_score=min_relevance_score,\n            with_embeddings=with_embedding,\n        )\n        if len(results) == 0:\n            raise ServiceResourceNotFoundError(\"No match found\")\n        return results[0]\n\n    async def __does_collection_exist(self, cur: Cursor, collection_name: str) -> bool:\n        results = await self.__get_collections(cur)\n        return collection_name in results\n\n    async def __get_collections(self, cur: Cursor) -> list[str]:\n        cur.execute(\n            \"\"\"\n            SELECT table_name\n            FROM information_schema.tables\n            WHERE table_schema = %s\n            \"\"\",\n            (self._schema,),\n        )\n        return [row[0] for row in cur.fetchall()]\n\n    def _check_dimensionality(self, dimension_num):","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/postgres/postgres_memory_store.py#L457-L493","documentation":"Raised by PostgresMemoryStore.get_nearest_match() when the underlying get_nearest_matches(limit=1) returns an empty list. Unlike the collection-missing case, the collection exists but no row cleared the min_relevance_score threshold. ServiceResourceNotFoundError with literal message 'No match found'.","triggerScenarios":"Calling `await store.get_nearest_match(collection_name, embedding, min_relevance_score=...)` on an existing collection where either the table is empty or every candidate scores below min_relevance_score.","commonSituations":"min_relevance_score set too high (e.g. > best cosine similarity); empty/freshly created collection; embedding from a different model than stored vectors (scores near 0); querying the wrong collection.","solutions":["Lower or remove min_relevance_score (default 0.0) and retry.","Use get_nearest_matches(limit, ...) directly and handle an empty list instead of relying on get_nearest_match() to throw.","Verify the collection has data and that query embeddings come from the same model/dimensionality.","Catch ServiceResourceNotFoundError and degrade to a fallback response."],"exampleFix":"// before\nbest = await store.get_nearest_match('mycol', emb, min_relevance_score=0.9)\n// after\nmatches = await store.get_nearest_matches('mycol', emb, limit=1, min_relevance_score=0.0)\nbest = matches[0] if matches else None","handlingStrategy":"try-catch","validationCode":"matches = await store.get_nearest_matches(collection_name, embedding, limit=1, min_relevance_score=min_relevance_score)\nbest = matches[0] if matches else None","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import ServiceResourceNotFoundError\ntry:\n    best = await store.get_nearest_match(collection_name, embedding, min_relevance_score)\nexcept ServiceResourceNotFoundError:\n    best = None","preventionTips":["Prefer get_nearest_matches(limit=1) over get_nearest_match() to avoid exception-based control flow.","Start with min_relevance_score=0.0 and tune up only after measuring score distributions.","Confirm query and stored embeddings come from the same model."],"tags":["postgres","memory-store","no-match","vector-search","service-resource-not-found"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}