Skip to content

feat(search): rebuild site search with ranked results and excerpts - #186

Merged
anttiviljami merged 1 commit into
mainfrom
claude/compassionate-newton-7bt3o7
Nov 11, 2026
Merged

anttiviljami merged 1 commit into
mainfrom
claude/compassionate-newton-7bt3o7

Conversation

@anttiviljami

Copy link
Copy Markdown
Member

Summary

Replaces @cmfcmf/docusaurus-search-local with a local search plugin in src/plugins/search. The old search had no usable ranking and did not cover the API reference.

What changed

Index (build time, indexer.js)

  • One record per section of every rendered doc and changelog page, with the real heading anchors and breadcrumbs. Code samples are kept apart from prose so they can be weighted lower.
  • Every operation of the OpenAPI specs in redoc.config.js (operationId, endpoint, summary, description), deep-linked to the Redoc anchor. About 1.5k operations; the API reference was not searchable before.
  • Listings, redirect stubs and pagination pages are left out. Any element can opt out with data-search-ignore.

Ranking (browser, engine.js)

  • BM25F over title, keys (operationId, endpoint, URL slug), context (page title, parent headings, breadcrumbs), body and code.
  • Query words match exactly, by word form ("authenticate" finds "Authentication", weighted below exact), by prefix while typing, and by edit distance for typos.
  • Sections matching every query word rank far above partial matches. A page titled like the query beats a section that mentions it. Phrase and proximity boosts.
  • Generated SDK/CLI reference pages and changelog entries rank below guides and the API reference.

UI (theme/SearchBar)

  • Dialog opened with Ctrl/⌘ K or /, results grouped by page, matched excerpt with highlighting per hit, endpoint badges for API operations.
  • Filters for Docs / API reference / Changelog with counts, keyboard navigation, dark mode, mobile layout.

Verification

  • Full production build passes. Index is 4.2 MB (877 KB gzipped, previously 6.4 MB), loaded on first use of search.
  • npm run test:search runs 67 real queries against the built index (topics, questions, identifiers, endpoints, partial typing, typos). All pass.
  • Browser-tested on the built site: results, keyboard navigation, anchor navigation on docs and API pages (same page and cross page), light/dark/mobile.

Notes for review

  • The build now fetches the 49 OpenAPI specs once more for the index. If a spec fails to load, the build still succeeds and only that API's operations are missing from search.
  • npm start has no index of its own; it serves the one from the last npm run build.
  • test:search is not wired into CI: its expectations are tied to current page URLs, so a renamed page would fail unrelated docs PRs.
  • cheerio, fs-extra and yaml are now declared as direct dependencies (they were transitive). yaml moved 1.10.2 → 1.10.3 in the lockfile.
  • i18n/en/code.json is removed: it only held a string of the old plugin.

Generated by Claude Code

Replace @cmfcmf/docusaurus-search-local with a local plugin
(src/plugins/search).

Index (build time)
- One record per section of every rendered doc and changelog page, with
  the real heading anchors, breadcrumbs and code samples kept apart from
  the prose.
- API reference: every operation of the OpenAPI specs in redoc.config.js
  (operationId, endpoint, summary, description), deep-linked to the
  Redoc anchor. The API reference was not searchable before.
- Listings, redirects and pagination pages are left out.

Ranking (browser)
- BM25F over title, keys (operationId, endpoint, URL slug), context
  (page title, parent headings, breadcrumbs), body and code.
- Query words match exactly, by word form (Porter stemming, weighted
  below exact), by prefix while typing, and by edit distance for typos.
- Sections matching every word rank far above partial matches; title,
  page, phrase and proximity boosts; generated SDK/CLI reference pages
  and changelog entries rank below guides and the API reference.

UI
- Search dialog (Ctrl/Cmd+K or /) with results grouped by page, matched
  excerpts with highlighting, endpoint badges, filters for docs, API
  reference and changelog, and keyboard navigation.

npm run test:search checks 67 queries against the built index.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CRtqyLatvXTimsB6sRCb8o
@anttiviljami
anttiviljami merged commit 45614a2 into main Nov 11, 2026
1 check passed
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