You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The HKP op=index endpoint currently returns results in an unspecified order (database insertion order). For a good user experience — especially for email or UID substring searches that may match many keys — results should be ranked by relevance.
Proposed ranking model
A combined score of two dimensions:
Edit-distance relevance — Levenshtein distance between the search term and the best-matching UID string. A lower distance means a better match. Can be normalised to [0, 1] as distance / max(len(term), len(uid)).
Actuality — recency of the key, measured by mtime (last modification time). A more recently updated key is weighted as more relevant.
A blended score e.g. 0.7 × normalised_levenshtein + 0.3 × normalised_age could be tuned later.
Implementation considerations
Levenshtein distance is not available as a standard JPQL function. Options:
PostgreSQL levenshtein() via a native query or a JPA function extension.
Pre-compute a normalised string representation in the DB for faster matching.
Compute in Java after loading the bounded result set (at most 5 000 entries).
Background
The HKP
op=indexendpoint currently returns results in an unspecified order (database insertion order). For a good user experience — especially for email or UID substring searches that may match many keys — results should be ranked by relevance.Proposed ranking model
A combined score of two dimensions:
[0, 1]asdistance / max(len(term), len(uid)).mtime(last modification time). A more recently updated key is weighted as more relevant.A blended score e.g.
0.7 × normalised_levenshtein + 0.3 × normalised_agecould be tuned later.Implementation considerations
levenshtein()via a native query or a JPA function extension.ORDER BYa DB-computed score, passing that ordering through to the second fetch.Acceptance criteria