Skip to content

Revamp docs search: product-keyed Algolia index, ranking fixes, denser modal - #2009

Open
enriquegh wants to merge 5 commits into
mainfrom
search-consolidated
Open

enriquegh wants to merge 5 commits into
mainfrom
search-consolidated

Conversation

@enriquegh

@enriquegh enriquegh commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Why

Docs search was not finding the page people wanted. Querying batch changes returns five Batch Changes sub-pages but not the Batch Changes page itself; code insights likewise lists Quickstart, repository scope, and troubleshooting pages without the Code Insights landing page. API key and SRC_ACCESS_TOKEN return the same -dump-requests … -get-curl CLI flag table five times from different src subcommands, because the docs say "access token" and the crawler indexes the boilerplate under every command page. SSO returns one page (Troubleshooting user authentication) five times, including its "On this page" heading, while the SAML setup guides are nowhere near the top. A question like how do I configure SSO gets five hits, none about SSO. And every hit is grouped under Platform, Documentation, CLI & API, or Code Management, which says nothing about which product it belongs to, with multi-line snippets that leave about four results on screen.

Two causes. The index was built by Algolia's crawler on the DocSearch tier: we could adjust settings in the Algolia dashboard, but every change was a manual UI edit outside the repo, and the record shape itself (what counts as a page, which product a hit belongs to, what content gets indexed) was whatever the crawler extracted from the rendered HTML. And the modal presented that hierarchy as-is, grouped by the crawler's lvl0 buckets with full multi-line snippets for every hit.

What we did

Moved to a new Algolia application (JSZOJ0ZYVG). The old app was on the free DocSearch tier, where the only way to get records into the index is Algolia's built-in crawler. The new one is a regular Algolia application, still on Algolia's free tier, so we can build and push the index ourselves from GitHub Actions on every merge to main: record shape, ranking settings, and synonyms live in the repo (dev/algolia-index.mjs) and get reviewed like any other change. The index name stays sourcegraph_docs and has already been rebuilt on the new app with the settings in this PR, so the modal here queries live data.

Build the index from the docs source (dev/algolia-index.mjs, .github/workflows/algolia-index.yml). Records come from the contentlayer output, keyed by product from src/data/navigation.ts, with product/section/type facets and a page-rank weight from seoPriority. Ranking fixes verified against the live index: no product boosts (they sat ahead of typo/attribute/exact in Algolia's ranking), product name excluded from searchable attributes so getting started no longer matches every record in that product, English stop words and plurals for question-style queries, synonyms (API key/access token, SSO/SAML/single sign-on, login/sign in, repo/repository, auth/authentication, perms/permissions, src-cli/src CLI), repeated boilerplate deduped by content hash, frontmatter stripped, and at most two hits per page. Result: 14,190 records across 506 pages, 1,310 duplicate blocks removed.

Make the modal show results people can scan (src/components/search/, src/data/search.ts). Results group by product with a filter chip row; each hit shows a Page › Heading breadcrumb with the match highlighted and an icon for page / heading / content; content hits get a one-line snippet and page/heading hits get none, so 8-10 results fit above the fold instead of 4. Page and heading matches sort ahead of content matches and duplicate snippets are dropped per group. The empty state offers curated starting points, the no-results screen links to products, the highlighted result is prefetched, Ctrl/Cmd+Enter opens it in a new tab, the query mirrors into ?search= so a search can be shared, and the modal is full height at 390px. Also clears the React 19 hooks lint warnings in the vendored DocSearch files (0 errors / 8 warnings, down from 39).

How it looks

Query authentication against the new index: product chip row, results grouped by product, Page › Heading breadcrumbs with the match highlighted, page / heading / content icons, one-line snippets only on content hits.

Search modal for "authentication": product chips, Administration group, highlighted breadcrumbs, page and heading icons

Results: main vs. this PR

Top 5 hits from the Algolia REST API with the same parameters. "main" is the crawler-built sourcegraph index on app 0EBA2NRQU3 that main queries today; "this PR" is sourcegraph_docs on JSZOJ0ZYVG.

Query main this PR
batch changes Viewing Batch Changes, Update a batch change, Site Admin Configuration, Running Server Side, Permissions — landing page absent Batch Changes › Batch Changes first, then Getting Started, Agentic Batch Changes, Viewing Batch Changes
code insights repository scope, use cases, troubleshooting, two Quickstarts — landing page absent Code Insights › Code Insights first, then Architecture, repository scope, use cases
API key five src repos …/src snapshot … flag tables, all the same -dump-requests boilerplate Revoking an access token, Creating an access token, GitLab access token scopes, Managing access tokens (via API key ↔ access token synonym)
SRC_ACCESS_TOKEN five src snapshot/src search-jobs flag tables Creating an access token, then Environment variables › SRC_ACCESS_TOKEN
SSO Troubleshooting user authentication (SSO) five times, including its "On this page" heading SAML, Troubleshooting SSO, Configuring SAML with OneLogin / Okta / ADFS
how do I configure SSO 5 hits: Connect agent FAQ, Getting Started, Administration FAQ, Audit Log, Site configuration reference 187 hits: SAML › Identity Providers, Add a SAML provider, ADFS, JumpCloud, Troubleshooting SSO
saml SAML page and four of its headings SAML, Troubleshooting SSO, OneLogin, Okta, ADFS guides (one page shows at most two hits)
getting started Getting Started page and four of its headings Getting Started page, then Getting Started sections of Batch Changes, MCP Server, Cody, Code Search
authetication MCP Authentication, Repository authentication, Authentication and authorization, … same pages, typo tolerance unchanged

Where main already ranked the right page first (saml, getting started, typos), the change is that a page no longer fills the list with its own headings, so other relevant pages show up, and every hit carries its product.

npx tsc --noEmit passes; node dev/algolia-index.mjs --dry-run --stats matches the pushed index.

Follow-ups

  • The ALGOLIA_ADMIN_API_KEY repo secret must be a key for app JSZOJ0ZYVG (addObject, deleteObject, deleteIndex, settings, editSettings, browse; indices sourcegraph_docs*) or the on-merge reindex will fail. The old crawler on the DocSearch app can be paused. This is done

Research behind these changes, comparing Plain, Amp, and Cursor docs search: https://ampcode.com/threads/T-01a0b0f1-e77c-76a8-84cc-9cd012b4fb0e

enriquegh and others added 4 commits September 17, 2026 22:44
Replaces the crawler-managed index with records built by dev/algolia-index.mjs
from the contentlayer output, keyed by product from src/data/navigation.ts.
Adds product filter chips and Page › Heading breadcrumbs to the search modal
and a workflow that reindexes on push to main.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0b0ef-f7ad-7413-9f23-e047e8da9b10
Co-authored-by: Amp <amp@ampcode.com>
Drops the product optionalFilters boosts, which sat ahead of typo/attribute/
exact in Algolia's ranking and pushed Agentic Batch Changes and Deep Search
hits above exact matches (batch changes, saml, SSO, getting started).
Removes hierarchy.lvl0 (product) from searchable attributes so a product
name in the query no longer matches every record in that product; adds
English stop words and plurals so question-style queries work; imports
synonyms (API key/access token, SSO/SAML/single sign-on, ...) into the temp
index before the atomic move; dedupes repeated boilerplate content blocks by
normalized hash; strips frontmatter; sets distinct to 2.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0b0ef-f7ad-7413-9f23-e047e8da9b10
Co-authored-by: Amp <amp@ampcode.com>
One scrollable product chip row with an overflow affordance; page/heading/
content icons per hit; match highlighting in breadcrumbs; one-line windowed
snippets and none on page or heading hits; page and heading hits sorted before
content hits with duplicate snippets removed per group; curated empty-state
suggestions; linked products on the no-results screen; route prefetch for the
highlighted hit; Ctrl/Cmd+Enter opens in a new tab; previous results stay
visible while loading; platform-aware shortcut hint; the query is mirrored to
?search= so a search can be shared; full-height modal at 390px. Also clears
the React 19 hooks lint warnings in the vendored DocSearch files.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0b0ef-f7ad-7413-9f23-e047e8da9b10
Co-authored-by: Amp <amp@ampcode.com>
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sourcegraph-docs Ready Ready Preview Sep 17, 2026 11:24pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

⚠️ Spell check found 3 issue(s) in this PR

Only findings on lines added by this PR, and in its title and description, are shown.

Pull request description

  • line 23, column 125
    • NRQUNRIA
  • line 28, column 69
    • Quickstartsquickstart
  • line 35, column 3
    • autheticationauthentication

Please correct the spelling, or add words which are correct to cspell-allow-list.txt.

Run npx cspell@10 --no-progress --dot '**/*' locally to check the full repository.

Swaps the old Algolia application ID for the new one in the allow list,
exempts Algolia's minWordSizefor* setting names inline, and rewords a
comment and a local variable.

Amp-Thread-ID: https://ampcode.com/threads/T-01a0b0ef-f7ad-7413-9f23-e047e8da9b10
Co-authored-by: Amp <amp@ampcode.com>

@marcleblanc2 marcleblanc2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it. Preview deployment works great!

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