Category or Brand Pages as Phrase Suggestions in Autocomplete¶
Overview¶
When a visitor interacts with the search assistant (autocomplete), they may expect to see suggestions for category pages or brand pages. By default, Elevate does not return category or brand pages as part of the suggestions in the autocomplete. This guide explains a workaround to allow category or brand pages suggestions to be part of the phrase suggestions in the autocomplete response.
Step-by-step Implementation¶
Step 1. Index Category Page References¶
To make category suggestions available in autocomplete, category or brand pages must be indexed as content.
Below is an example of how to add category and brand pages as content in the data feed:
{"replace":{"key":"c1","content":{"markets":["uk"],"type":"category","defaults":{"title":"Dresses","url":"/dresses"}}}}
{"replace":{"key":"b2","content":{"markets":["uk"],"type":"brand","defaults":{"title":"Acme Co.","url":"/acme-co"}}}}
Step 2. Querying Autocomplete with Category Suggestions¶
Once categories are indexed, content must be requested using a POST method when calling the autocomplete
endpoint/method.
Example¶
//request-body.json
{
"contentLists": [
{
"id": "category-suggestions",
"contentFilter": {
"type": ["category"]
}
},
{
"id": "brand-suggestions",
"contentFilter": {
"type": ["brand"]
}
}
]
}
#!/bin/bash
curl -X POST \
"https://{{cluster-id}}.elevate-api.cloud/api/storefront/v3/queries/autocomplete?market=US&locale=en-US&sessionKey=4b116e34-0a7a-ce5d-5591-75c62f231967&customerKey=4b116e34-0a7a-ce5d-5591-75c62f231967&touchpoint=DESKTOP&q=acme" \
-H 'Content-Type: application/json' \
-d @request-body.json
const api = esales({
clusterId: "cluster-id",
market: "uk",
locale: "en-GB",
touchpoint: "desktop",
session: () => ({
customerKey: "0b05119e-eeb8-418a-bbfb-defa0dde417",
sessionKey: "0b05119e-eeb8-418a-bbfb-defa0dde417"
})
});
const results = await api.query.autocomplete(
{ q: "acme" },
{
"contentLists": [
{
"id": "category-suggestions",
"contentFilter": { "type": ["category"] }
},
{
"id": "brand-suggestions",
"contentFilter": { "type": ["brand"] }
}
]
}
);
The "type"
value must match the one used in the data feed.
Behavior and Limitations¶
- Empty pages, i.e., pages that contains no product listing, will still appear as suggestions in autocomplete responses.
- Elevate treats these as generic content, without awareness of connections to actual category pages.
Best Practices and Summary¶
- Use meaningful words like
"category"
or"brand"
as thetype
value for clarity. - Add keywords to maximize discoverability.
- Test the autocomplete queries to ensure that the correct categories appear, and the visitors get redirected to the correct category or brand page.