For autocomplete, you can edit the "minLength" option. You will need to use this hook: beforeAutocompleteOptions. If for example you want this to run when three characters are entered, you would write options.minLength=3
. The full example snippet might look something like
algolia.registerHook('beforeAutocompleteOptions', function(options) {
options.minLength=3
return options;
});
For instantSearch you'd want to call the beforeInstantSearchInit hook and change the searchFunction For example, if we used the snippet noted here for changing search option, this may look like
algolia.registerHook('beforeInstantsearchInit', function(instantsearchOptions, algoliaBundle) {
instantsearchOptions.searchFunction = function(helper) {
if (helper.state.query.length > 3) {
helper.search();
}
}
return instantsearchOptions;
});
These snippets can go anywhere after the hooks are defined, and may vary according to your implementation.
Last reviewed 29-04-22.
Comments
0 comments
Article is closed for comments.