Repository navigation
Conversation
A query that exactly matches a candidate's declared keyword verbatim (e.g. "table of contents" against Outline's own literal keyword) could still fail to surface it at all, if enough other candidates each happened to match one of the query's individual words separately. The multi-word token-sum path sums per-word scores plus a coverage bonus, and that sum regularly exceeded the fixed 90-point ceiling for an exact keyword match, since dozens of Table-related templates each matched "table" and "contents" independently. An exact whole-phrase match against a candidate's name or a declared keyword is now promoted to a reserved top tier (its score plus 100), safely above the token-sum path's mathematical ceiling (~151), so it always outranks a candidate that only coincidentally contains several of the query's individual words. Single-word queries and queries that don't exactly match a name/keyword are unaffected. Verified against the issue's own repro table: "table of contents" and "heading navigation" now surface Outline first, matching the five already-working examples the issue cited (copy button, markdown renderer, mobile drawer, data visualization), which are unaffected. A nonsense query still returns nothing.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
No established em-dash convention in this file's prose comments (only in its describe-block titles), unlike search.mjs itself.
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
|
Thanks for looking into this. I don't think #5239 was fully specified enough to be ready for implementation. Before changing the ranking, we'd want regression coverage showing that existing good searches don't get worse, and I'm not sure we have a solid search-quality benchmark yet. I wouldn't spend any more of your tokens on this for now. |
cixzhang
left a comment
There was a problem hiding this comment.
Builders can find Outline by its declared phrases. Both regressions move from absent to first; focused suites pass. mobile drawer also improves from fifth to first.
[Reviewed by Robohands]
…5289) * fix(cli): rank exact keyword phrase matches above token-sum scores A query that exactly matches a candidate's declared keyword verbatim (e.g. "table of contents" against Outline's own literal keyword) could still fail to surface it at all, if enough other candidates each happened to match one of the query's individual words separately. The multi-word token-sum path sums per-word scores plus a coverage bonus, and that sum regularly exceeded the fixed 90-point ceiling for an exact keyword match, since dozens of Table-related templates each matched "table" and "contents" independently. An exact whole-phrase match against a candidate's name or a declared keyword is now promoted to a reserved top tier (its score plus 100), safely above the token-sum path's mathematical ceiling (~151), so it always outranks a candidate that only coincidentally contains several of the query's individual words. Single-word queries and queries that don't exactly match a name/keyword are unaffected. Verified against the issue's own repro table: "table of contents" and "heading navigation" now surface Outline first, matching the five already-working examples the issue cited (copy button, markdown renderer, mobile drawer, data visualization), which are unaffected. A nonsense query still returns nothing. * fix: remove em dash from test comment No established em-dash convention in this file's prose comments (only in its describe-block titles), unlike search.mjs itself.
scoreQuery's signature says every hit carries matched/total, and #5320 added them, but the promote tier #5289 added returns before that. tsc catches it, so sync:api-types fails and `pnpm build` is red on main. A whole-phrase hit answered the whole query by definition, which is what asFull already means - so reuse it and override the score.
Fixes #5239 (the first, cheapest of the issue's suggested fixes: "rank exact whole-phrase keyword matches above partial name-token matches").
Problem
astryx search "table of contents"never surfacedOutline, even thoughOutline.doc.mjsdeclares'table of contents'verbatim as a keyword. Traced precisely:scoreCandidatecorrectly computes an exact-keyword score of 90 for Outline against that query. The bug is thatscoreQuery's multi-word token-sum path (which scores"table"and"contents"as separate tokens against every OTHER candidate) regularly produces scores above 90, since dozens of Table-related templates and components each match one of those two common words independently. With the default--limit 20, roughly 53 other candidates outscored Outline's exact match, pushing it out of the results entirely.Same root cause for
"heading navigation"against Outline's'heading navigation'keyword.Fix
When the full, untokenized query exactly matches a candidate's name or a declared keyword verbatim (
scoreCandidatescore 90 or 100, the only two outcomes at or above that mark), promote it to a reserved top tier (score + 100) that's safely above the token-sum path's mathematical ceiling (~151: 100 avg + 36 matched-count bonus + 15 coverage bonus). This is a targeted priority rule, not a rebalancing of the existing 0-100 scale, so it can't regress any query that doesn't have a genuine exact whole-phrase match.Scope (intentionally narrow)
This addresses exactly suggestion #1 from the issue, "no metadata changes anywhere." The issue's second, narrower bug ("on this page" returning zero results because a query consisting entirely of stopwords has no fallback) is a separate, vaguer problem the issue itself frames as needing more judgment ("relax to a ranked OR... though it is a band-aid"), so I left it out of this PR rather than bundle a riskier, less-verified change into the same fix. Happy to take that on separately if useful.
Verification
Ran every query from the issue's own reproduction table against the real component registry, before and after:
table of contentsheading navigationcopy button(already worked)markdown renderer(already worked)mobile drawer(already worked)data visualization(already worked)zzzzqqqx(nonsense)Added two regression tests (a new "exact keyword phrase outranks incidental token matches" describe block, matching the file's existing em-dash naming convention for its own describe blocks) asserting Outline ranks first for both previously-failing queries, plus a nonsense-query sanity check. Both fail against the pre-fix implementation (verified by temporarily reverting just the implementation file) and pass with the fix.
Full
searchandbuildAPI test suites pass (19 tests;build's own ranking floors inkit.mjsare all>=threshold checks, so this monotonic score increase for exact matches can only makebuildmore confident about a genuine keyword match, never less). Lint and typecheck (tsconfig.strict.json) show no new issues; a pre-existing, unrelated failure incomponent.test.mjs(a case-sensitivity assertion, confirmed failing identically on a clean baseline with my changes fully reverted) is untouched by this diff.