JavaScript
How a search client works
InstantSearch is the UI layer that sits on top of Algolia’s search client layer, with a state managed by the Algolia search helper layer. These three layers are interchangeable so that you can use the InstantSearch widgets with a different search client. The search client queries Algolia’s servers whenever users refines a search. You can build a custom search client to add custom behavior. For example, to perform backend searches with InstantSearch.Implementing a proxy
To prevent the initial empty query, you must wrap a custom search client around Algolia’s, and pass it toinstantsearch. The custom search client acts as a proxy for search requests:
All examples in this guide assume you’ve included InstantSearch.js in your web page from a CDN. If, instead, you’re using it with a package manager, adjust how you import InstantSearch.js and its widgets for more information.
JavaScript
search method. In this case, you only call it when performing a query.
You can also use a proxy to only begin searching after a certain number of characters have been typed by adding a condition, for example,
query.length > 3.Detecting empty search requests
If you don’t want to perform a search request when the query is empty (""),
you need to detect it:
JavaScript
Sometimes, one user action results in multiple queries, for example, clicking on an
refinementList or using multiple index widgets. Make sure that every query is empty before intercepting the function call.requests array. Each object requires at least these properties: hits, nbHits, and processingTimeMS.
JavaScript
instantsearch widget, like this:
JavaScript