Skip to content

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

Open
barbara-celi wants to merge 53 commits into
mainfrom
EDU-17906
Open

[EDU-17906] feat: implement Hybrid Search API integration#456
barbara-celi wants to merge 53 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 0c8a13a
🔍 Latest deploy log https://app.netlify.com/projects/leafy-mooncake-7c2e5e/deploys/6a4ecdaf6df235000866165b
😎 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.
Add an after:spec inter-spec settle (default 3s, env-overridable) so the
Netlify preview's per-IP throttle window (B-5) decays between specs, and
document the serial execution + spec ordering rationale in cypress.config.cjs.
github-actions[bot]
github-actions Bot previously approved these changes Jun 25, 2026
Move the 20s timeout onto the single descendant selector that yields the
count badge so the async-count assertion inherits the full retry window
instead of .find()'s 5s default, fixing the beforeEach count-gate flake.
github-actions[bot]
github-actions Bot previously approved these changes Jun 25, 2026
…3s (T-42)

Wraps cy.visit with a cy.request gate that retries non-2xx (esp. B-5
preview 403s) and page-load timeouts with exponential backoff before
visiting, so a cold/throttled doc page lands as a fast cache hit instead
of failing. Replaces bare cy.visit across the 9 doc-page specs.
github-actions[bot]
github-actions Bot previously approved these changes Jun 26, 2026
…t settle (T-47)

Adds a configurable settle delay before each cy.visit inside visitWithRetry,
gated by CYPRESS_PRE_VISIT_SETTLE_MS (default 1500ms, 0 disables). Widens
the gap between the ~107 per-run page-load bursts to reduce per-IP request
rate under Netlify's abuse heuristic (B-5).
…e-decay window (T-48)

Increase INTER_SPEC_SETTLE_MS default from 3000 to 8000 in plugins/index.js so
Netlify's per-IP throttle window (B-5) has more time to decay between spec starts.
Still overridable via CYPRESS_INTER_SPEC_SETTLE_MS.
…efore() hooks (T-49)

Replace visitWithRetry gate-cy.request+visit pair with cy.intercept capture:
one origin hit per attempt instead of two, and visit-level 403/5xx now
self-heal (closes the V-42 gap). Remove before() warmUp from the 6 specs
whose paths the workflow pre-warm (T-44) already covers statically
(locale-switching, search-locale, search-pagination, search-regression,
search-results, search-doctype-filter). Keep dynamic in-spec warming for
copy-for-llm and helpcenter-navigation-status (runtime-derived URLs).
github-actions[bot]
github-actions Bot previously approved these changes Jun 29, 2026
…7e54532)

feat/hybrid-search now includes main's TroubleshootingCard, ListingFilter,
and related exports from v6.1.1, so the helpcenter build no longer fails
with missing-export TypeScript errors after the main merge.
github-actions[bot]
github-actions Bot previously approved these changes Jun 29, 2026
The homepage (/) redirects to /en/ with a 307. visitWithRetry was
retrying on any non-2xx, causing locale-switching to fail with
"returned HTTP 307 after 5 attempts". cy.visit follows redirects
automatically — only 4xx/5xx need a retry.
github-actions[bot]
github-actions Bot previously approved these changes Jun 29, 2026
The vitest runner fails to start on any test file that statically imports
from 'vitest' in the current toolchain. Drop those imports and rely on the
existing globals: true config so the suites boot and execute again.
Accept an optional doctype on the hybrid search client and the /api/search
proxy, validate it against the fixed doctype allowlist, and forward it
upstream only when valid. Absent or invalid values preserve the current
unfiltered behavior; the response echoes doctype only when applied. Adds
unit coverage for the validation and passthrough.
github-actions[bot]
github-actions Bot previously approved these changes Jul 8, 2026
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