Skip to main content
The SearchService class (accessed via client.search) provides both traditional keyword-based search and advanced AI-powered semantic search capabilities.

Methods

searchProducts

Fast, keyword-based search optimized for exact matches, SKUs, and product names. It uses case-insensitive partial matching to find relevant results quickly.
Response

semanticSearch

AI-powered, meaning-based search that understands intent and context. This allows customers to find products using natural language descriptions even if they don’t know the exact product name.
Key Support: Both Secret Keys and Publishable Keys are supported for semantic search, allowing you to implement AI-powered search directly in your frontend.
Response

Personalized results

Pass personalize: true together with a signed-in customer’s session token (the x-auth-token header) to nudge results toward that shopper’s preferences. Query relevance stays primary — relevance is blended with the shopper’s preference signal, not replaced — so results remain on-topic. Without a customer session, or for a shopper with no preference signal yet, ranking is by query relevance only.

Comparison: Text vs. Semantic


Zero-Result Fallback: A powerful UX pattern is to first call searchProducts. If totalResults is 0, gracefully fallback to semanticSearch to suggest products that might still interest the user.

Why is semanticSearch a POST? POST /v1/search is intentionally accessible to publishable keys despite using the POST verb. It is a read-only operation — POST is used purely to support complex JSON request bodies (query, minScore, filters). No state is mutated and no 403 is returned for publishable keys.

Response Codes

Both methods accept publishable and secret keys. searchProducts is GET; semanticSearch is POST (read-only).