Skip to content

[feature][search] Add env-gated Algolia DocSearch alongside local search#3955

Open
dataroaring wants to merge 1 commit into
apache:masterfrom
dataroaring:enable-algolia-search
Open

[feature][search] Add env-gated Algolia DocSearch alongside local search#3955
dataroaring wants to merge 1 commit into
apache:masterfrom
dataroaring:enable-algolia-search

Conversation

@dataroaring

Copy link
Copy Markdown
Contributor

What

Enable Apache Doris docs to opt into Algolia DocSearch without removing the existing local search (@yang1666204/docusaurus-search-local).

Why

The Algolia Crawler needs a domain-verification token served from robots.txt, and we want to A/B Algolia against the current local search before fully cutting over rather than swapping it out in one step.

Changes

File Change
static/robots.txt Add Algolia Crawler domain-verification token
docusaurus.config.js USE_ALGOLIA build flag; conditionally load the Algolia theme + themeConfig.algolia (read from env); expose customFields.useAlgolia
src/theme/SearchBar/index.js Swizzle renders Algolia's bar or the local bar at runtime based on customFields.useAlgolia
package.json Pin @docusaurus/theme-search-algolia@3.6.3 as a direct dependency

Design notes

  • Additive, not a replacement. The local-search theme stays loaded in both modes so its @generated index module (which the proxiedGenerated swizzle depends on) keeps compiling.
  • Modal-only DocSearch (searchPagePath: false) so it doesn't collide with the local /search route. contextualSearch: true keeps results scoped per version/locale.
  • Default behavior is unchanged: with USE_ALGOLIA unset, the site builds and serves the existing local search exactly as before.

How to enable

USE_ALGOLIA=true \
ALGOLIA_APP_ID=xxxx \
ALGOLIA_SEARCH_API_KEY=xxxx \   # search-only public key
ALGOLIA_INDEX_NAME=doris \
yarn build

Testing

  • Default (local-search) path: config passes node --check; logically untouched.
  • ⚠️ The USE_ALGOLIA=true path has not been built end-to-end here (requires live Algolia credentials). Import path/default export for the Algolia SearchBar were verified, but a real USE_ALGOLIA=true build should be run before relying on it.

🤖 Generated with Claude Code

Enable Apache Doris docs to opt into Algolia DocSearch without removing the
existing local search:

- Add the Algolia Crawler domain-verification token to static/robots.txt.
- Add a USE_ALGOLIA build flag. When set, load @docusaurus/theme-search-algolia
  alongside the local-search theme and inject themeConfig.algolia from
  ALGOLIA_APP_ID / ALGOLIA_SEARCH_API_KEY / ALGOLIA_INDEX_NAME env vars.
- The local-search theme stays loaded so its @generated index module keeps
  compiling; the SearchBar swizzle now chooses Algolia vs local at runtime via
  customFields.useAlgolia. DocSearch runs modal-only (searchPagePath:false) so
  it doesn't collide with the local /search route.
- Pin @docusaurus/theme-search-algolia as a direct dependency.

Default behavior is unchanged: with USE_ALGOLIA unset the site builds and
serves the existing local search exactly as before.
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.

1 participant