fix: use max() instead of min() in LinkResolver search fallback

The search fallback (strategy 5) was using min() to select the best match
from FTS results, which selected the WORST match instead of the best.
On both SQLite and Postgres backends, higher scores indicate better matches
(FTS rank, vector similarity normalized to [0,1], hybrid fusion). Using max()
correctly returns the highest-scoring result.

Fixes #640

Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
Signed-off-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
This commit is contained in:
claude[bot]
2026-03-02 16:42:11 +00:00
parent 8b7f39ee9b
commit 0b915b76ce
2 changed files with 50 additions and 1 deletions
+1 -1
View File
@@ -302,7 +302,7 @@ class LinkResolver:
if results:
# Look for best match
best_match = min(results, key=lambda x: x.score) # pyright: ignore
best_match = max(results, key=lambda x: x.score) # pyright: ignore
logger.trace(
f"Selected best match from {len(results)} results: {best_match.permalink}"
)