[EDU-17906] feat: implement Hybrid Search API integration#456
Conversation
- 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.
✅ Deploy Preview for leafy-mooncake-7c2e5e ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- 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.
|
O deploy preview ainda roda algolia. Notei que a flag No local aqui também roda algolia, mesmo depois de instalar a dependência da branch |
| /** | ||
| * Reusable client for the VTEX Docs Hybrid Search API. | ||
| * | ||
| * This module is intentionally framework-agnostic (no Next.js / React |
There was a problem hiding this comment.
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.
- 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.
…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.
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.
…eview Runs the Cypress doctype/snippet spec against the PR deploy preview so counts regressions and stale bundles are caught on every push.
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.
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.
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.
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.
The merge-base changed after approval.
Remove the dedicated doctype-filter Action so PRs wait on one Netlify-backed E2E job; keep search-doctype-filter coverage in the full suite.
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.
PedroAntunesCosta
left a comment
There was a problem hiding this comment.
Approving. The review items from the earlier pass are resolved:
- CDN cache keying now uses
Netlify-Vary: query(replacesVary: Accept-Language), keying the edge cache on the query string as intended. HS_DEFAULT_LIMITis now10, consistent withitemsPerPage: 10, the docs, and the tests.- Doctype counts come from the dedicated
/api/search/countsendpoint (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.
2532715
What is the purpose of this pull request?
This PR implements a new
/api/searchendpoint in the Help Center that proxies requests to the VTEX Docs Hybrid Search API.The implementation includes:
/api/search) that validates input, handles errors, and applies CDN caching.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:
help-center).@vtexdocs/componentsand shared with the Dev Portal.How should this be manually tested?
@vtexdocs/componentspoints to the branch with hybrid search support. For this task, I'm working on thefeat/hybrid-searchbranch. Important: This change is only needed for testing until thevtexdocs/componentsPR merges to main. Revert this before committing your final changes.yarn installto fetch the updated components.yarn dev.Screenshots or example usage
Types of changes