This page describes the API of Fredhopper Suggest Search.
Pure JSON request
JSON Request
The format to retrieve suggestions for a specific term:
/suggest/json?search=KEYWORD&scope=//UNIVERSE/LOCALE
For example, to get suggestion for shi in the universe catalog01 in American English:
/suggest/json?search=shi&scope=//catalog01/en_US
Response message
The JSON interface returns suggestions for each index in the following format:
{"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>"},
...
]
},
...
]}
For example, the following return message contains:
- Two keyword suggestions for nicam and nicky
- One category suggestion for Mens / Nightwear (providing additional information about the number of results and the Fredhopper Location String)
{"suggestionGroups":[
{
"indexName":"Keywords",
"indexTitle":"Keywords",
"suggestions":[
{"searchterm":"nicam"},
{"searchterm":"nicky"}
]
},
{
"indexName":"Categories",
"indexTitle":"Categories",
"suggestions":[
{"nrResults":17,
"fhLocation":"//catalog01/en_US/categories<{catalog01_15003}",
"mlValue":"Mens / Nightwear"}
]
}
]}
JSON wrapped in a javascript function call (JSONP)
JSCRIPT request
The format to retrieve suggestions for a specific term:
/suggest/jscript?search=KEYWORD&scope=//UNIVERSE/LOCALE&callback=FUNCTIONNAME
For example, to get suggestion for shi in the universe catalog01 in American English, wrapped in the function "dropdown":
/suggest/jscript?search=shi&scope=//catalog01/en_US&callback=dropdown
| If you execute a jscript without specifying a callback, the JSON will be wrapped in the function "updateSuggestions" by default. |
Response message
The JSCRIPT interface returns suggestions for each index wrapped in the specified callback in the following format:
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>"},
...
]
},
...
]})
For example, the following return message contains:
- Two keyword suggestions for nicam and nicky
- One category suggestion for Mens / Nightwear (providing additional information about the #results and the Fredhopper Location String)
- A callback named "testFunction"
testFunction({"suggestionGroups":[
{
"indexName":"Keywords",
"indexTitle":"Keywords",
"suggestions":[
{"searchterm":"nicam"},
{"searchterm":"nicky"}
]
},
{
"indexName":"Categories",
"indexTitle":"Categories",
"suggestions":[
{"nrResults":17,
"fhLocation":"//catalog01/en_US/categories<{catalog01_15003}",
"mlValue":"Mens / Nightwear"}
]
}
]}
The Query API sorts the index entries alphabetically, it also ensures that the most relevant suggestions are returned first.
| The available fields and values are only depending on your specific Suggest index - there is no limitations which and how many fields are returned for a suggestion. This can be fully tailored to your needs. The Suggest Query API itself does not make assumptions about which fields it delivers, i.e. the API is generic comparable to how attributes are delivered in the FAS Query API. |
Comments
0 comments
Please sign in to leave a comment.