SearchSuggestion resource (Shop API 23.2)

Summary

Http Method Resource Description
GET /search_suggestion Provides keyword search functionality for products, categories, content, brands and custom suggestions. Returns suggested products, suggested categories, suggested content, suggested brands and custom suggestions for the given search phrase.

Get search suggestions

Provides keyword search functionality for products, categories, content, brands and custom suggestions. Returns suggested products, suggested categories, suggested content, suggested brands and custom suggestions for the given search phrase.

Url

GET http://hostname:port/dw/shop/v23_2/search_suggestion?q={String}&count={Integer}&currency={String}&locale={String}

Formats

json, xml

Authentication

Name Description
JWT Authentication via Customer JWT.
None No authentication.

Response Document

SuggestionResult

Query Parameters

Parameter Type Description Constraints
count Integer The maximum number of suggestions per request. Default value is 5. This affects all types of suggestions (category, product, content, brand, custom suggestions). maxIntegerValue=10, minIntegerValue=1
currency String The currency mnemonic specified for price. This parameter is effective only for product suggestions.  
locale String    
q String The query phrase to search for. maxLength=50, minLength=3, nullable=false

Customization

This Resource supports server-side customization.

Extension Point Method Detail
dw.ocapi.shop.search_suggestion.beforeGET

beforeGET () : Status

The function is called before the request will be processed.

Returns:
a non-null Status ends the hook execution
dw.ocapi.shop.search_suggestion.modifyGETResponse

modifyGETResponse (doc : SuggestionResult ) : Status

The function is called after the request has been processed.

Parameters:
doc - the document
Returns:
a non-null Status ends the hook execution

Sample

REQUEST:
GET /dw/shop/v23_2/search_suggestion?q=shi&count=1&currency=EUR HTTP/1.1
Host: example.com
Content-Type: application/json; charset=UTF-8

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Cache-Control: max-age=900,must-revalidate
Content-Length: 1337

{
  "_v" : "23.2",
  "brand_suggestions": {
    "brands": [
      "Sega"
    ],
    "suggested_phrases": [
      {
        "exact_match": false,
        "phrase": "Sega"
      }
    ],
    "suggested_terms": [
      {
        "original_term": "shi",
        "terms": [
          {
            "completed": false,
            "corrected": true,
            "exact_match": false,
            "value": "sega"
          }
        ]
      }
    ]
  },
  "category_suggestions": {
    "categories": [
      {
        "id": "mens-clothing-dress-shirts",
        "link": "http://example.com/dw/shop/v23_2/categories/mens-clothing-dress-shirts?count=1&q=shi&currency=EUR",
        "name": "Dress Shirts",
        "parent_category_name": "Clothing"
      }
    ],
    "suggested_phrases": [
      {
        "exact_match": false,
        "phrase": "Dress Shirts"
      }
    ],
    "suggested_terms": [
      {
        "original_term": "shi",
        "terms": [
          {
            "completed": true,
            "corrected": false,
            "exact_match": false,
            "value": "shirts"
          }
        ]
      }
    ]
  },
  "content_suggestions": {
    "content": [
      {
        "id": "super-save-shipping",
        "link": "http://example.com/dw/shop/v23_2/content/super-save-shipping?count=1&q=shi&currency=EUR",
        "name": "Super Saver Shipping"
      }
    ],
    "suggested_phrases": [
      {
        "exact_match": false,
        "phrase": "shipping"
      }
    ],
    "suggested_terms": [
      {
        "original_term": "shi",
        "terms": [
          {
            "completed": true,
            "corrected": false,
            "exact_match": false,
            "value": "shipping"
          }
        ]
      }
    ]
  },
  "custom_suggestions": {
    "custom_suggestions": [
      "Point and Shoot"
    ],
    "suggested_phrases": [
      {
        "exact_match": false,
        "phrase": "Point and Shoot"
      }
    ],
    "suggested_terms": [
      {
        "original_term": "shi",
        "terms": [
          {
            "completed": false,
            "corrected": true,
            "exact_match": false,
            "value": "shoot"
          },
          {
            "completed": false,
            "corrected": true,
            "exact_match": false,
            "value": "short"
          }
        ]
      }
    ]
  },
  "product_suggestions": {
    "products": [
      {
        "currency": "EUR",
        "link": "http://example.com/dw/shop/v23_2/products/25591125?count=1&q=shi&currency=EUR",
        "price": 29.51,
        "product_id": "25591125",
        "product_name": "Striped Shirt"
      }
    ],
    "suggested_phrases": [
      {
        "exact_match": false,
        "phrase": "shirt"
      }
    ],
    "suggested_terms": [
      {
        "original_term": "shi",
        "terms": [
          {
            "completed": true,
            "corrected": false,
            "exact_match": false,
            "value": "shirt"
          },
          {
            "completed": true,
            "corrected": false,
            "exact_match": false,
            "value": "shirts"
          }
        ]
      }
    ]
  },
  "query": "shi"
}
X OCAPI versions 15.x and 16.x will be retired on March 31, 2021. For dates and more information, see the OCAPI versioning and deprecation policy and this Knowledge Article.