microsoft/semantic-kernel · error · ServiceResourceNotFoundError
No match found
Error message
No match found
What it means
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'.
Source
Thrown at python/semantic_kernel/connectors/memory_stores/postgres/postgres_memory_store.py:475
Args:
collection_name: The name of the collection to get the nearest match from.
embedding: The embedding to find the nearest match to.
min_relevance_score: The minimum relevance score of the match. (default: {0.0})
with_embedding: Whether to include the embedding in the result. (default: {False})
Returns:
Tuple[MemoryRecord, float]: The record and the relevance score.
"""
results = await self.get_nearest_matches(
collection_name=collection_name,
embedding=embedding,
limit=1,
min_relevance_score=min_relevance_score,
with_embeddings=with_embedding,
)
if len(results) == 0:
raise ServiceResourceNotFoundError("No match found")
return results[0]
async def __does_collection_exist(self, cur: Cursor, collection_name: str) -> bool:
results = await self.__get_collections(cur)
return collection_name in results
async def __get_collections(self, cur: Cursor) -> list[str]:
cur.execute(
"""
SELECT table_name
FROM information_schema.tables
WHERE table_schema = %s
""",
(self._schema,),
)
return [row[0] for row in cur.fetchall()]
def _check_dimensionality(self, dimension_num):View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before
best = await store.get_nearest_match('mycol', emb, min_relevance_score=0.9)
// after
matches = await store.get_nearest_matches('mycol', emb, limit=1, min_relevance_score=0.0)
best = matches[0] if matches else None Defensive patterns
Strategy: try-catch
Validate before calling
matches = await store.get_nearest_matches(collection_name, embedding, limit=1, min_relevance_score=min_relevance_score) best = matches[0] if matches else None
Try / catch
from semantic_kernel.exceptions import ServiceResourceNotFoundError
try:
best = await store.get_nearest_match(collection_name, embedding, min_relevance_score)
except ServiceResourceNotFoundError:
best = None Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Key not found
- Failed to create Postgres settings.
- Collection '{collection_name}' does not exist
- Upsert failed
- Dimensionality of {dimension_num} exceeds the maximum allowe
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/8738d30adbedf0e9.
Report an issue: GitHub.