Skip to content

feat(search): smarter ranking, hex disambiguation, numeric dedup#1662

Draft
gregnazario wants to merge 3 commits into
mainfrom
cursor/smarter-search-relevance-ranking-ddc0
Draft

feat(search): smarter ranking, hex disambiguation, numeric dedup#1662
gregnazario wants to merge 3 commits into
mainfrom
cursor/smarter-search-relevance-ranking-ddc0

Conversation

@gregnazario

@gregnazario gregnazario commented May 30, 2026

Copy link
Copy Markdown
Contributor

Description

Several related improvements that make explorer search smarter and more intent-aware. Matching/filtering thresholds are unchanged throughout — only result ordering / de-duplication improves. No new dependencies, no network behavior changes.

1. Relevance ranking for assets and known addresses

Coin / fungible-asset results and known-address label results are now ordered by how well they match the query rather than purely by the static Panora popularity index (coinOrderIndex).

A new pure relevance scorer in app/pages/layout/Search/searchUtils.ts:

  • scoreTextMatch(query, candidate) — exact (100) > prefix (75) > word-boundary prefix (50) > substring (25) > none (0).
  • scoreCoinRelevance(query, coin) — exact asset address paste is the strongest signal (1000); otherwise the best text match across symbol, panoraSymbol, and name, with symbol matches edging out equally-tiered name matches.
  • scoreLabelRelevance(query, label) — relevance for known-address names.

handleCoinLookup / handleLabelLookup sort by relevance first, keeping coinOrderIndex only as a tie-breaker. So USDC surfaces the coin whose symbol is USDC first even when a more "popular" coin merely contains USDC as a substring.

2. Ambiguous 64-char hex disambiguation

A fully-expanded 64-character hex is ambiguous — transaction hash (/txn/…) vs 32-byte address. groupSearchResults now accepts a prioritizeTransactions option; both the header autocomplete (Index.tsx, including its cache path) and the home / full-page search (SearchWithResults.tsx) pass it for is32Hex queries, so a confirmed transaction is surfaced first and wins the Enter-key / ?search= auto-navigate. Non-hex queries keep the existing order.

3. Numeric (block height vs transaction version) de-duplication

A bare number is searched three ways: block by height (/block/N), transaction by version (/txn/N), and the block containing version N (/block/{containing height}). All three destinations were already correct — the block route only accepts a height, which is exactly why version→height resolution exists. But near genesis a block's height can equal the version it contains, so the height lookup and the containing-block lookup resolved to the same /block/…, rendering two near-identical "Block" rows. A new pure buildNumericSearchResults helper drops the containing-block entry when it points to the same block as the height lookup.

Related Links

  • Spec: FEAT-SEARCH-002 / FEAT-SEARCH-003 in docs/FEATURES_SPECIFICATION.md updated for all three changes.

Checklist

  • pnpm fmt — clean
  • pnpm lint (tsc + Biome) — clean
  • pnpm test --run app/pages/layout/Search/ app/pages/Search/ — 78 passed (5 files): new searchRanking.test.ts, plus new prioritizeTransactions and buildNumericSearchResults cases in searchFiltering.test.ts
  • CHANGELOG.md updated under [Unreleased]
  • docs/FEATURES_SPECIFICATION.md updated (FEAT-SEARCH-002 / FEAT-SEARCH-003 + Appendix B coverage)
Open in Web Open in Cursor 

Co-authored-by: Greg Nazario <greg@gnazar.io>
@netlify

netlify Bot commented May 30, 2026

Copy link
Copy Markdown

Deploy Preview for aptos-explorer ready!

Name Link
🔨 Latest commit ad1d3ff
🔍 Latest deploy log https://app.netlify.com/projects/aptos-explorer/deploys/6a1b1f4597336000089b894e
😎 Deploy Preview https://deploy-preview-1662--aptos-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 51 (🔴 down 1 from production)
Accessibility: 98 (no change from production)
Best Practices: 83 (🔴 down 9 from production)
SEO: 92 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 4.82kB (0.05%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
aptos-explorer-client-esm 6.17MB 1.02kB (0.02%) ⬆️
aptos-explorer-server-esm 2.02MB 3.79kB (0.19%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: aptos-explorer-server-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/searchUtils-*.js 3.63kB 51.87kB 7.53% ⚠️
assets/PageHeader-*.js 117 bytes 14.95kB 0.79%
assets/routes-*.js 47 bytes 14.61kB 0.32%

Files in assets/searchUtils-*.js:

  • ./app/pages/layout/Search/searchUtils.ts → Total Size: 16.12kB

Files in assets/PageHeader-*.js:

  • ./app/pages/layout/Search/Index.tsx → Total Size: 10.34kB

Files in assets/routes-*.js:

  • ./app/pages/Search/SearchWithResults.tsx → Total Size: 10.31kB
view changes for bundle: aptos-explorer-client-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/searchUtils-*.js 912 bytes 25.29kB 3.74%
assets/routes-*.js 35 bytes 7.53kB 0.47%
assets/PageHeader-*.js 73 bytes 6.69kB 1.1%

Files in assets/searchUtils-*.js:

  • ./app/pages/layout/Search/searchUtils.ts → Total Size: 13.71kB

Files in assets/routes-*.js:

  • ./app/pages/Search/SearchWithResults.tsx → Total Size: 10.91kB

Files in assets/PageHeader-*.js:

  • ./app/pages/layout/Search/Index.tsx → Total Size: 10.75kB

@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.69%. Comparing base (600ff53) to head (ad1d3ff).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
app/pages/layout/Search/searchUtils.ts 96.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1662      +/-   ##
==========================================
+ Coverage   32.04%   32.69%   +0.65%     
==========================================
  Files         188      188              
  Lines        8666     8716      +50     
  Branches     3251     3269      +18     
==========================================
+ Hits         2777     2850      +73     
+ Misses       5885     5862      -23     
  Partials        4        4              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cursor cursor Bot changed the title feat(search): rank asset and label results by match relevance feat(search): smarter ranking + ambiguous 64-char hex disambiguation May 30, 2026
@cursor cursor Bot changed the title feat(search): smarter ranking + ambiguous 64-char hex disambiguation feat(search): smarter ranking, hex disambiguation, numeric dedup May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants