Index setup
Before using the query suggestions plugin, you need to create an Algolia with the expected format. You can either use the dashboard, or use the API clients.Installation
First, you need to install the plugin.JavaScript
script element:
HTML
Example
This example uses the plugin withinautocomplete-js,
along with the algoliasearch API client.
JavaScript
JavaScript
Parameters
SearchClient
required
The initialized Algolia search client.
string
required
The index name.
(params: { state: AutocompleteState }) => SearchParameters
A function returning Algolia search parameters.
(params: { source: AutocompleteSource, state: AutocompleteState, onTapAhead: () => void })
This function takes the original source as a parameter and returns a modified version of that source.Example: change Autocomplete stateUsually, when a link in the Autocomplete menu is selected, the menu closes.
However, to keep the menu visible after a selection is made,
use Example: create linksTurns Query Suggestions into clickable Google search links:
transformSource to set the isOpen state:JavaScript
string | string[]
The attribute or attribute path to display categories for.
JavaScript
number
default:1
How many items to display categories for.
number
default:1
The number of categories to display per item.