InstantSearch is a front-end library that you can use to display your results and that works with the search-as-you-type UX pattern as default. This is the responsible for sending requests to our servers on every keystroke.
It is possible to set up your search so that a search is only triggered after the user has entered a certain number of characters.
To do this, create a function that will check the length of the search query and only trigger a search once there are enough characters (in this example 3):
/** * Our custom filter function where we add our string length check before the query
gets sent off to Algolia * @param {*} helper */ function customFilters(helper) { if (helper.state.query) { const search_string = helper.state.query; if (search_string.length < 3) { return false; } // Will only trigger when more than three characters have been typed console.log('More than three characters have been typed'); helper.search(); } }
Then you'll need to add this to as your search function:
searchFunction: customFilters
You can see an example that shows how it works here.
This can reduce the number of search operations and reduce the cost. However, please note that this may cause users to perceive the search to be lagging. To prevent this, you could display some placeholder content.