The Suggest query API is completely independent to the Fredhopper Access Server (FAS) query API that is used for site navigation and search. The query strings are simple, no authentication is required to process the request and the responses are lightweight in order to allow faster transfer and processing by the browser.
The composition of the Suggest query strings follows a simple format that requires a valid scope and the search term value to be provided. The resultant query string should be appended to the endpoint that is given to you by your Technical Consultant and sent using the GET method. We offer the response in either a pure JSON-format or as JSON wrapped in a JavaScript function. Please find some example query strings below:
JSON-format template:
/suggest/json?scope=//UNIVERSE/LOCALE&search=KEYWORD
JSON-format example:
/suggest/json?scope=//catalog01/en_GB&search=trainers
JSCRIPT-format template:
/suggest/jscript?scope=//UNIVERSE/LOCALE&search=KEYWORD&callback=FUNCTIONNAME
JSCRIPT-format example:
/suggest/jscript?scope=//catalog01/en_GB&search=trainers&callback=dropdown
Each time a user makes a keystroke action in the search bar, the front-end should generate a new query request and send it to the Suggest API with the amended search term (KEYWORD). Caching of the responses can be considered in order to avoid many duplicated requests within a given time period.
The response that you receive back from will contain the suggestions for each index in the following format:
JSON-format response template:
{"suggestionGroups":[
{
"indexName":"<INDEX_NAME>",
"indexTitle":"<INDEX_NAME>",
"suggestions":[
{"<FIELD_A_1>":"<VALUE_A_1>",
"<FIELD_A_2>":"<VALUE_A_2>"},
{"<FIELD_B_1>":"<VALUE_B_1>",
"<FIELD_B_2>":"<VALUE_B_2>"},
...
]
},
...
]}
JSCRIPT-format response template:
callback(
{"suggestionGroups":[
{
"indexName":"<INDEX_NAME>",
"indexTitle":"<INDEX_NAME>",
"suggestions":[
{"<FIELD_A_1>":"<VALUE_A_1>",
"<FIELD_A_2>":"<VALUE_A_2>"},
{"<FIELD_B_1>":"<VALUE_B_1>",
"<FIELD_B_2>":"<VALUE_B_2>"},
...
]
},
...
]})
Comments
0 comments
Please sign in to leave a comment.