Skip to content

chore(search): Tune Algolia ranking to favor title and relevance#17825

Merged
coolguyzone merged 3 commits into
masterfrom
coolguyzone/chore/tune-algolia-search-ranking
May 27, 2026
Merged

chore(search): Tune Algolia ranking to favor title and relevance#17825
coolguyzone merged 3 commits into
masterfrom
coolguyzone/chore/tune-algolia-search-ranking

Conversation

@coolguyzone
Copy link
Copy Markdown
Contributor

@coolguyzone coolguyzone commented May 20, 2026

DESCRIBE YOUR PR

Tune Algolia docs search so it leans on titles and textual relevance over SDK popularity, and so SDK-agnostic product docs surface above individual SDK pages on broad queries.

Commit 1 — Ranking and searchable-attributes override

Override the index settings pushed by scripts/algolia.ts on top of the defaults from @sentry-internal/global-search:

  • Add title as the first searchable attribute. The package's default searchableAttributes only includes section, keywords, and text — so page titles never contributed to matching unless they happened to also be a heading on the page. With title first, title matches outrank section and body matches via Algolia's attribute ranking criterion.
  • Move asc(popularity) to the last position in the ranking array. It was running ahead of attribute, exact, and proximity, which meant a popular SDK page with a ## Tracing heading would outrank the actual Tracing product page on a "Tracing" query. Textual relevance now decides first; popularity is a final tiebreaker.

Commit 2 — Boost SDK-agnostic product docs

Pages outside platforms/ previously fell back to Number.MAX_SAFE_INTEGER for the popularity field, so they always lost the asc(popularity) tiebreaker to any SDK page. Pages whose slug starts with product/, concepts/, cli/, guides/, or integrations/ now get popularity: 0 — better than every individual SDK — so they surface above SDK pages on broad queries.

This composes correctly with platform filtering: the platform optionalFilters boost runs at the filters ranking criterion, which sits ahead of asc(popularity). So a user with Python selected still gets Python-relevant pages first; product pages come second (and only beat non-matching SDK pages).

Left attributeForDistinct: 'section' unchanged for now — the above should be enough on its own, and changing distinct behavior is a bigger behavior shift worth testing separately if needed.

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

Testing note

The ranking-settings override (commit 1) only takes effect when scripts/algolia.ts runs at deploy time against the production Algolia index, so a Vercel preview won't exercise it — preview deploys point at the existing index. To validate before merge, either tweak the index's "Searchable attributes" and "Ranking and Sorting" settings directly in the Algolia dashboard (non-destructive, easy to revert) or stand up a one-off staging index by overriding DOCS_INDEX_NAME.

The popularity boost (commit 2) changes per-record data, so it'll only fully take effect after the next full reindex on master.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

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

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview, Comment May 27, 2026 11:06pm
sentry-docs Ready Ready Preview, Comment May 27, 2026 11:06pm

Request Review

Copy link
Copy Markdown
Contributor

@sfanahata sfanahata left a comment

Choose a reason for hiding this comment

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

Search on! 🚀

@sfanahata
Copy link
Copy Markdown
Contributor

@coolguyzone approved, but looks like a rebase is needed.

Not blocking, but adding this note, just in case tweaking is possible in this way:

If I was being nitty about building logic around our search, I would say default to this on every search bar, except when /platforms/ is selected. Because if I'm in the SDKs section, it may be nice to bias toward SDK doc results as the top, especially if it prioritizes showing me the platform/framework I have selected.

Search does that today, it just does that no matter where I am in docs. And it's just clearly broken on the home page.

coolguyzone and others added 2 commits May 27, 2026 15:53
Override the index settings pushed by scripts/algolia.ts so search
results lean on titles and textual relevance instead of SDK popularity.

- Add `title` as the first searchable attribute. Previously only
  `section`, `keywords`, and `text` were searched, so page titles like
  "Tracing" didn't contribute to matching unless they happened to also
  be a heading on the page.
- Move `asc(popularity)` to the last position in the ranking criteria.
  It was running ahead of `attribute`, `exact`, and `proximity`, which
  meant a popular SDK page with a "Tracing" heading would outrank the
  Tracing product page on a "Tracing" query. Textual relevance now
  decides first; popularity is a final tiebreaker.

Co-Authored-By: Claude <noreply@anthropic.com>
Pages outside `platforms/` previously fell back to `MAX_SAFE_INTEGER`
for the popularity field, so they always lost the `asc(popularity)`
ranking tiebreaker to any SDK page. That meant queries like "Tracing"
or "Sentry CLI" surfaced random SDK pages instead of the product or
CLI docs that match the query subject more directly.

Treat product/concept/CLI/guides/integrations pages as the most
popular non-platform group by giving them popularity 0 (better than
every individual SDK). The platform `optionalFilters` boost still
runs ahead of popularity in the ranking pipeline, so users who have
a platform selected keep getting platform-relevant results first.

Co-Authored-By: Claude <noreply@anthropic.com>
@coolguyzone coolguyzone force-pushed the coolguyzone/chore/tune-algolia-search-ranking branch from 0d65a7d to 0e10bf0 Compare May 27, 2026 22:53
@coolguyzone coolguyzone merged commit 60d57d8 into master May 27, 2026
23 checks passed
@coolguyzone coolguyzone deleted the coolguyzone/chore/tune-algolia-search-ranking branch May 27, 2026 23:08
@coolguyzone coolguyzone linked an issue Jun 1, 2026 that may be closed by this pull request
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.

Look Into Algolia Search Issues on Docs

2 participants