Product Suggestions

The suggestions can be used to implement a basic auto-complete functionality.

The source of data for suggestions is the searchKeyword field in a product (see ProductData).

Representations

Suggestion

SuggestionResult

The result can contain several such pairs, see the product search keywords suggest example.

Suggest Query

Endpoint: /{projectKey}/product-projections/suggest
Method: GET
OAuth2 Scopes: view_products:{projectKey}
Response Representation: SuggestionResult
Query Parameters:

Example suggest request

GET /{projectKey}/product-projections/suggest?searchKeywords.en=knife&fuzzy=true&staged=true&limit=5

Product Search Keywords Suggest Examples

Consider a product with the following searchKeywords:

{
  "en": [{
    "text": "Multi tool"
  }, {
    "text": "Swiss Army Knife",
    "suggestTokenizer": {
      "type": "whitespace"
    }
  }],
  "de": [{
    "text": "Schweizer Messer",
    "suggestTokenizer": {
      "type": "custom",
      "inputs": ["schweizer messer", "offiziersmesser", "sackmesser"]
    }
  }]
}

No Tokenizer

GET /{projectKey}/product-projections/suggest?searchKeywords.en=multi will return

{ "searchKeywords.en": [{"text": "Multi tool"}] }

since multi is a prefix of “Multi tool”.

GET /{projectKey}/product-projections/suggest?searchKeywords.en=tool returns no results since “Multi tool” does not have a tokenizer set.

Whitespace Tokenizer

GET /{projectKey}/product-projections/suggest?searchKeywords.en=kni will return

{ "searchKeywords.en": [{"text": "Swiss Army Knife"}] }

since the text “Swiss Army Knife” uses a whitespace tokenizer and kni is a prefix of “Knife”.

Custom Tokenizer

GET /{projectKey}/product-projections/suggest?searchKeywords.de=offiz will return

{ "searchKeywords.de": [{"text": "Schweizer Messer"}] }

since the text “Schweizer Messer” uses a custom tokenizer and offiz is a prefix of one of the tokenizer inputs.

Suggestions For Two Languages

GET /{projectKey}/product-projections/suggest?searchKeywords.de=offiz&searchKeywords.en=multi will return

{
  "searchKeywords.de": [{"text": "Schweizer Messer"}],
  "searchKeywords.en": [{"text": "Multi tool"}]
}