feat(search): rank results by relevance, surfacing name/title matches first#209
Open
SimplyThomas wants to merge 1 commit into
Open
feat(search): rank results by relevance, surfacing name/title matches first#209SimplyThomas wants to merge 1 commit into
SimplyThomas wants to merge 1 commit into
Conversation
… first The finder's free-text search was a pure boolean substring filter: a saint either contained all query tokens somewhere in its haystack or it didn't, with no notion of where the match landed. Matching saints were then ordered by feast day, so searching a name or title surfaced whoever had the earliest feast — e.g. 'Theotokos' ranked the Virgin Mary #2 and 'Virgin Mary' ranked her #5, behind saints who merely mention the words in their notes or carry 'Virgin' in a rank. Add scoreMatch(): a tiered relevance score grading WHERE the query matched — display name (exact > prefix > whole-word > substring) far above Also-Known-As, above name variants, above a deep-haystack-only hit (the haystack mixes in every facet value, brief, and notes). sortByRelevance() orders by that score with the reader's chosen Sort mode as the tiebreak. The finder uses it whenever a query is present; with the box empty, the Sort dropdown drives order as before. The Virgin Mary now ranks #1 for both 'Theotokos' and 'Virgin Mary'.
Deploying orthodox-saints with
|
| Latest commit: |
fbfdf71
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://09f6b2a4.orthodox-saints.pages.dev |
| Branch Preview URL: | https://worktree-search-ranking-weig.orthodox-saints.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Adds relevance ranking to the finder's free-text search. Previously search was a pure boolean substring filter and matching saints were ordered by feast day, so searching a name or title surfaced whoever had the earliest feast — e.g. "Theotokos" ranked the Virgin Mary #2 and "Virgin Mary" ranked her #5, behind saints who merely mention the words in their notes or carry "Virgin" in a rank. (The search haystack mixes name + Also-Known-As + every facet value + brief + notes into one string, so any of them matched equally.)
New
scoreMatch()grades where the query matched — display name (exact > prefix > whole-word > substring) far above Also-Known-As, above name variants, above a deep-haystack-only hit.sortByRelevance()orders by that score with the reader's chosen Sort dropdown as the tiebreak. The finder uses it whenever a query is present; with the box empty, the Sort dropdown drives order exactly as before.Result, verified against the real 2740-saint dataset: the Virgin Mary (OS-0001) now ranks #1 for both "Theotokos" (was #2) and "Virgin Mary" (was #5). Runners-up are sensible name matches (e.g. "Righteous Mary, grandmother of the Theotokos").
This directly supports the "find a saint they share a name with" discovery path (CLAUDE.md §1).
Preview
🔎 Preview: (paste the Cloudflare Pages URL once its check is green)
Checklist
src/) — no generatedpublic//dist/files.data/vocabulary.csvfirst. (n/a — no vocab change)make validateis CLEAN — zero violations. (n/a — no data/build.py change; data.json unchanged)make testpasses (ifbuild.pychanged). (n/a — build.py untouched)Sourcesfilled; no fabricated facts; no copyrighted hymns/images. (n/a — no data change)Notes for review
src/lib/filter.ts,src/islands/finder.client.ts, + newsrc/lib/filter.test.ts). No data, nobuild.py, no schema changes.astro buildsucceeds (2768 pages).frontendgate will cover it.🤖 Generated with Claude Code