Search suggestions

POST /indexes/{index_name}/recommendations/queries

Purpose

Help shoppers find relevant products faster by suggesting query terms as they type. Reduces zero-results and accelerates navigation to high-intent pages.

When to use

  • Search bar suggestions on desktop and mobile
  • Inline suggestions within site-wide navigation

Example uses

  • Search as you type, show popular queries after typing in 2-3 characters

Example (cURL)

curl -X POST "https://api.marqo.ai/indexes/product-catalog/recommendations/queries" \
  -H "x-marqo-index-id: ${MARQO_INDEX_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "iph",
    "limit": 5
  }'

Parameters

NameTypeRequiredDescriptionExample
qstringyesPartial query text typed by the user."iph"
limitintegernoMax number of suggestions. Default 10.5
userIdstringnoOptional user identifier for personalization."abc123"
sessionIdstringnoOptional session identifier."xyz789"
If q is not provided (or an empty string), top limit queries will be returned.

Response (example)

{
  "suggestions": [
    {"suggestion": "iphone 15 case"},
    {"suggestion": "iphone charger"},
    {"suggestion": "iphone screen protector"},
    {"suggestion": "iphone 14 pro"},
    {"suggestion": "iphone accessories"}
  ]
}