SearchaheadSearch Store API functions
The searchahead endpoint of the Query API searches a collection of data for relevant partial-term matches to user-specified search terms. It powers the searchahead feature in your search application’s UI, which displays real-time query matches as the user types. The query matches improve as the user continues typing.
Pass a value as a string. The value must be three characters or more in length. Alternatively, pass a JSON object to include optional parameters.
Example requests
- Required parameters
window.getSearchStore().searchahead('QUERY')
- Required and optional parameters
window.getSearchStore().searchahead({
query: 'QUERY',
page: PAGE,
limit: LIMIT,
sort: [{
sortField: 'SORT_FIELD',
sortOrder: 'SORT_ORDER'
}],
fieldList: ['FIELD_1', 'FIELD_2'],
highlight: HIGHLIGHT_BOOLEAN,
filters: [{
field: 'FIELD',
values: ['VALUE_1', 'VALUE_2']
}],
analyticsData: true
})
| The preceding example demonstrates the required parameters and some optional parameters to pass with this function. For full details on all parameters and allowed values, see the Query API configuration spec. |
Demo
The following CodePen resource demonstrates the usage of this function. Open your browser’s web console and network monitor logs and watch for activity after clicking the buttons that trigger the Search Store API function.
|
Edit the function and click the corresponding button again to see the result change. |