By default a search is triggered after every keystroke. If you want to change the default behaviour, and trigger a search only after a certain number of characters have been typed, you can use the queryHook function.
The queryHook function is called just before a search is triggered.
For example, you can limit the search to only trigger once at least 3 characters have been typed:
searchBox({
container: '#searchbox',
queryHook(query, search) {
if (query.length >= 3) {
search(query);
}
},
}),
You can see an example of this functionality here: https://codesandbox.io/p/sandbox/beautiful-lederberg-jz7rth.
Although this approach will reduce the number of search operations (and potentially the cost), it can also lead to users perceiving the delay as unwanted lag.