Skip to content

[EDU-17906] feat: implement Hybrid Search API integration#456

Merged
PedroAntunesCosta merged 66 commits into
mainfrom
EDU-17906
Jul 14, 2026
Merged

[EDU-17906] feat: implement Hybrid Search API integration#456
PedroAntunesCosta merged 66 commits into
mainfrom
EDU-17906

Conversation

@barbara-celi

@barbara-celi barbara-celi commented May 5, 2026

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request?

This PR implements a new /api/search endpoint in the Help Center that proxies requests to the VTEX Docs Hybrid Search API.
The implementation includes:

  • A Next.js API route (/api/search) that validates input, handles errors, and applies CDN caching.
  • A reusable, framework-agnostic hybrid search client (hybrid-search-client.ts) designed to be shared between Help Center and Dev Portal.

What problem is this solving?

EDU-17906 - Implement hybrid search: Help Center implementation

The Help Center currently relies entirely on Algolia for search. This implementation:

  • Creates the backend infrastructure needed to consume the new hybrid search API.
  • Ensures only Help Center content is returned (hardcoded source=help-center).
  • Provides a secure server-side proxy so the hybrid search API key never reaches the browser.
  • Establishes a reusable pattern that can be lifted to @vtexdocs/components and shared with the Dev Portal.

How should this be manually tested?

  1. Update the components dependency (temporary, do not commit): In package.json, ensure @vtexdocs/components points to the branch with hybrid search support. For this task, I'm working on the feat/hybrid-search branch. Important: This change is only needed for testing until the vtexdocs/components PR merges to main. Revert this before committing your final changes.
"@vtexdocs/components": "https://github.com/vtexdocs/components.git#feat/hybrid-search"
  1. Run yarn install to fetch the updated components.
  2. Add environment variables to Netlify:
# Hybrid Search (VTEX Docs API)
NEXT_PUBLIC_HYBRID_SEARCH_ENABLED=true
HS_API_ENDPOINT=https://vtexdocs-edge.vtex.com
HS_API_KEY=(obtain from the hybrid search API credentials)
  1. Run yarn dev.

Screenshots or example usage

image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Requires change to documentation, which has been updated accordingly.

- Added a new API endpoint `/api/search` that proxies requests to the VTEX Docs Hybrid Search API.
- Implemented query parameter handling, including validation and default limits.
- Introduced caching for successful responses at the CDN edge.
- Created a reusable Hybrid Search client for API interactions.
- Added comprehensive unit tests for the API handler and client functionality.
- Documented the setup and usage in a new `hybrid-search-setup.md` file.
@netlify

netlify Bot commented May 5, 2026

Copy link
Copy Markdown

Deploy Preview for leafy-mooncake-7c2e5e ready!

Name Link
🔨 Latest commit 2532715
🔍 Latest deploy log https://app.netlify.com/projects/leafy-mooncake-7c2e5e/deploys/6a5683c96641270008fbc8ac
😎 Deploy Preview https://deploy-preview-456--leafy-mooncake-7c2e5e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@barbara-celi barbara-celi self-assigned this May 5, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['release-no', 'release-auto', 'release-patch', 'release-minor', 'release-major']

@barbara-celi barbara-celi added the release-auto Automatic version bump label May 5, 2026
github-actions[bot]
github-actions Bot previously approved these changes May 5, 2026
@barbara-celi barbara-celi added release-minor Minor version bump and removed release-auto Automatic version bump labels May 5, 2026
- Clarified the purpose of the `NEXT_PUBLIC_HYBRID_SEARCH_ENABLED` variable.
- Added detailed steps for enabling hybrid search in local development and Netlify deployment.
- Included a note about the need for a rebuild when using the `NEXT_PUBLIC_` prefix.
github-actions[bot]
github-actions Bot previously approved these changes May 7, 2026
@PedroAntunesCosta

PedroAntunesCosta commented May 7, 2026

Copy link
Copy Markdown
Contributor

O deploy preview ainda roda algolia. Notei que a flag NEXT_PUBLIC_HYBRID_SEARCH_ENABLED aparece na documentação mas não aparece no código.

No local aqui também roda algolia, mesmo depois de instalar a dependência da branch feat/hybrid-search

/**
* Reusable client for the VTEX Docs Hybrid Search API.
*
* This module is intentionally framework-agnostic (no Next.js / React

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.

Acho que esse cliente deveria ser implementado no components. Mas o Cursor falou que isso pode abrir uma vulnerabilidade. Então acho que podemos estudar essa migração com mais calma durante o rollout.

O que acha @brunoamui ?

- Updated library config to support hybrid search via NEXT_PUBLIC_HYBRID_SEARCH_ENABLED
- Configured settings for Algolia and hybrid search backends with API endpoints
… troubleshooting pages

- Updated translation files to include new messages for results found.
- Enhanced the respective pages to display the number of results found based on user filters.
github-actions[bot]
github-actions Bot previously approved these changes May 18, 2026
- Modified the Search component to accept an itemsPerPage prop, setting it to 10.
- Increased the default limit for hybrid search results from 10 to 50.
github-actions[bot]
github-actions Bot previously approved these changes May 18, 2026
…n library config

- Removed the itemsPerPage prop from the Search component.
- Set the default itemsPerPage value to 10 in the library configuration for hybrid search.
github-actions[bot]
github-actions Bot previously approved these changes May 18, 2026
Required so the Netlify deploy preview resolves the hybrid search
adapter that libraryConfig.ts wires up.
The /api/search and /api/search/counts proxies set public CDN cache
headers but no query-aware vary, so Netlify's edge cached the first
query's response under the bare path and replayed it for every
subsequent query (counts and results never refreshed on a new search).

Set `Netlify-Vary: query` on both routes so the edge cache key includes
q/locale/doctype. Adds unit assertions on both routes plus permanent
e2e cross-query and request-shape regressions.
github-actions[bot]
github-actions Bot previously approved these changes Jul 10, 2026
…eview

Runs the Cypress doctype/snippet spec against the PR deploy preview so counts
regressions and stale bundles are caught on every push.
github-actions[bot]
github-actions Bot previously approved these changes Jul 10, 2026
Adds a preinstall purge of node_modules/@vtexdocs/components plus a
COMPONENTS_GIT_SHA build-cache fingerprint so the pinned commit is always
installed instead of a stale build restored from Netlify's dependency cache.
github-actions[bot]
github-actions Bot previously approved these changes Jul 10, 2026
The preinstall purge removed only the package folder, but yarn 1 skips
re-linking it because node_modules/.yarn-integrity still marked it satisfied,
breaking the build with "Cannot find module '@vtexdocs/components'". Removing
the integrity file forces a real install pass that restores the pinned SHA.
github-actions[bot]
github-actions Bot previously approved these changes Jul 10, 2026
Points the pinned components git dependency at the merged
feat/hybrid-search HEAD, which now includes the callout icon inline-SVG
fix from components main. Keeps the split-test branch deploy in sync
with production so both traffic groups render callout icons identically.
Updates package.json, yarn.lock, and the netlify.toml cache-key SHA in
lockstep.
github-actions[bot]
github-actions Bot previously approved these changes Jul 13, 2026
Resolve package.json/yarn.lock conflicts from main's #484 components bump
(pin #v6.1.3) by keeping the hybrid-search pin #4674bd6. That build is a
superset of v6.1.3 (it merged 6.1.3 in) and additionally carries the
hybrid-search adapter this PR depends on, so no callout fix is lost.
@PedroAntunesCosta
PedroAntunesCosta dismissed github-actions[bot]’s stale review July 13, 2026 17:40

The merge-base changed after approval.

github-actions[bot]
github-actions Bot previously approved these changes Jul 13, 2026
Remove the dedicated doctype-filter Action so PRs wait on one Netlify-backed
E2E job; keep search-doctype-filter coverage in the full suite.
github-actions[bot]
github-actions Bot previously approved these changes Jul 13, 2026
Re-query the DOM inside a single retrying `.should(callback)` when checking
that a new query refreshes the result list and the "All" badge, instead of
pinning a node via `.first().invoke('text')` across a React re-render. Keeps
the "title changed vs. previous query" and "All badge changed" checks so a
genuine stale-results regression still fails the test.
github-actions[bot]
github-actions Bot previously approved these changes Jul 14, 2026

@PedroAntunesCosta PedroAntunesCosta 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.

Approving. The review items from the earlier pass are resolved:

  • CDN cache keying now uses Netlify-Vary: query (replaces Vary: Accept-Language), keying the edge cache on the query string as intended.
  • HS_DEFAULT_LIMIT is now 10, consistent with itemsPerPage: 10, the docs, and the tests.
  • Doctype counts come from the dedicated /api/search/counts endpoint (real per-type totals + total), with distinct per-query values verified on the deploy preview.
  • Pagination / infinite-scroll behavior confirmed on the deploy preview.

The full e2e suite is green on Deploy Preview #456. Good to merge after the go-live sign-off.

Repoint from the pre-release commit pin to the published v6.2.0 tag and
update the Netlify cache-bust fingerprint to the commit it resolves to.
@PedroAntunesCosta
PedroAntunesCosta dismissed stale reviews from github-actions[bot] and themself via 2532715 July 14, 2026 18:45
@PedroAntunesCosta
PedroAntunesCosta merged commit 6a790a8 into main Jul 14, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-minor Minor version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants