Skip to content

feat(theme-search-algolia)!: upgrade to DocSearch v5 (AI-assisted) - #12406

Open
8bittitan wants to merge 3 commits into
facebook:mainfrom
8bittitan:feat/docsearch-upgrade-v5
Open

feat(theme-search-algolia)!: upgrade to DocSearch v5 (AI-assisted)#12406
8bittitan wants to merge 3 commits into
facebook:mainfrom
8bittitan:feat/docsearch-upgrade-v5

Conversation

@8bittitan

@8bittitan 8bittitan commented Sep 3, 2026

Copy link
Copy Markdown

Motivation

Upgrades @docsearch/react from v4 to v5 and removes the DocSearch v3
compatibility layer that was carried during the v3/v4 transition period.

DocSearch v5 drops the old v3 APIs and introduces multi-index search and
Agent Studio-based Ask AI, neither of which can be expressed with the previous
single-index (indexName + top-level searchParameters) configuration. This PR
migrates the theme config surface accordingly.

This is the first PR in a stack. Documentation updates (search.mdx) will
follow in a separate stacked PR.

What changed

  • Bump @docsearch/react to ^5.0.4 (+ lockfile)
  • Replace algolia.indexName and top-level algolia.searchParameters with an
    algolia.indices array (accepts string or {name, searchParameters} entries)
  • Load the search vs. Ask AI modal via dedicated dynamic entry points
    (@docsearch/react/modal / @docsearch/react/askaiModal)
  • Migrate Ask AI to Agent Studio: assistantIdagentId, per-index
    searchParameters, and new memory / promptSuggestions options
  • Convert contextual facetFilters into Agent Studio filters strings
    (new facetFiltersToFilterString / mergeFilters utilities)
  • Remove v3 version detection, webpack module aliases, ambient module
    declarations, and the ensureAskAISupported guard
  • Refresh SearchTranslations for v5 labels

Breaking changes

  • Who does this affect: all sites using @docusaurus/theme-search-algolia
  • How to migrate:
    • Replace indexName: 'x' with indices: ['x']
    • Move any top-level searchParameters into the relevant index entry:
      indices: [{name: 'x', searchParameters: {...}}]
    • Rename Ask AI assistantIdagentId
    • Ensure @docsearch/react v5 is installed
  • Why make this breaking change: DocSearch v5 removes v3 APIs and adds
    multi-index + Agent Studio Ask AI, which the old single-index config cannot express
  • Severity: high reach (every Algolia search user) × low-to-medium effort
    (mostly a config rename)
// Before
algolia: {
  appId: '...',
  apiKey: '...',
  indexName: 'docusaurus-2',
  searchParameters: {facetFilters: ['language:en']},
  askAi: {assistantId: 'RgIMYFUmTfrN'},
}

// After
algolia: {
  appId: '...',
  apiKey: '...',
  indices: [{name: 'docusaurus-2', searchParameters: {facetFilters: ['language:en']}}],
  askAi: {agentId: 'RgIMYFUmTfrN'},
}

Bundle size

Configuration Lazy modal chunk
Search only ~257.8 kB
Search + Ask AI ~554.7 kB

Note

There is an open issue to track removing the @base-ui/react dep from DocSearch here, which would reduce the overall bundles by ~51 kB.

Test Plan

  • pnpm --filter @docusaurus/theme-search-algolia build
  • pnpm test packages/docusaurus-theme-search-algolia
  • pnpm --filter @docusaurus/theme-translations run update (sync catalogs)
  • pnpm --filter website typecheck
  • pnpm build:website:fast and manually verify search + modal open/close

Test links

Deploy preview: https://deploy-preview-12406--docusaurus-2.netlify.app/

Related issues/PRs

…ndices config (AI-assisted)

Upgrade @docsearch/react from v4 to v5 and drop the DocSearch v3
compatibility layer that was carried during the v3/v4 transition.

Changes:
- Bump @docsearch/react to ^5.0.4 and update the lockfile
- Replace `algolia.indexName` + top-level `searchParameters` with an
  `algolia.indices` array (string or {name, searchParameters} entries)
- Load the search vs. Ask AI modal via dedicated dynamic entry points
- Migrate Ask AI to Agent Studio: `assistantId` -> `agentId`, per-index
  `searchParameters`, and add `memory` / `promptSuggestions` options
- Convert contextual `facetFilters` into Agent Studio `filters` strings
  (new facetFiltersToFilterString / mergeFilters utils)
- Remove v3 version detection, module aliases, ambient declarations, and
  the ensureAskAISupported guard
- Refresh SearchTranslations for v5 labels and update tests
- Migrate website dogfooding configs to `indices` and adjust DocSearch CSS

BREAKING CHANGE: `algolia.indexName` and top-level `algolia.searchParameters`
are removed in favor of `algolia.indices`. Ask AI now uses `agentId` instead
of `assistantId`. DocSearch v3 is no longer supported.

- Who does this affect: all sites using @docusaurus/theme-search-algolia
- How to migrate: replace `indexName: 'x'` with `indices: ['x']`; move
  `searchParameters` into the relevant index entry; rename Ask AI
  `assistantId` to `agentId`; ensure `@docsearch/react` v5 is installed
- Why make this breaking change: DocSearch v5 drops v3 APIs and introduces
  multi-index + Agent Studio Ask AI, which cannot be expressed with the old
  single-index config
- Severity: high reach (every Algolia search user) x low-to-medium effort
  (mostly a config rename)
@meta-cla

meta-cla Bot commented Sep 3, 2026

Copy link
Copy Markdown

Hi @8bittitan!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@socket-security

socket-security Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​docsearch/​react@​4.6.3 ⏵ 5.0.499 +31008599 +9100

View full report

@netlify

netlify Bot commented Sep 3, 2026

Copy link
Copy Markdown

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 4e18304
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a9af687b9995300089cd355
😎 Deploy Preview https://deploy-preview-12406--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@meta-cla

meta-cla Bot commented Sep 3, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Sep 3, 2026
8bittitan and others added 2 commits September 4, 2026 12:37
- Correct lint script typo lint:SPELLING -> lint:spelling
- Fix "noisey" -> "noisy" typo in webpack warning comment
- Add "askai" to project-words.txt and cSpell:ignore IMYF in config
- Temporarily disable translation-consistency test (it.todo); translations
  are deferred to a follow-up PR to keep this PR small
@8bittitan
8bittitan marked this pull request as ready for review September 4, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant