Is Autocomplete expensive in production?

I want to implement autocomplete in my flutter app, but this would require sending algolia search requests every time the text field changes. Wouldn’t this eat up my units very quickly if it’s 1000 requests/unit?

Hi Ali,

Traditionally, autocomplete experiences are as-you-type, meaning it refreshes for every query. In an Algolia context, it means indeed that every keystroke sends a new request to Algolia, counting towards your search requests. So, when typing “apple”, you get five search requests: “a”, “ap”, “app”, “appl” and “apple”.

Now, if you’re using one of our official API clients to perform requests, keep in mind that we cache queries and results on the client. For example, when using our Autocomplete library together with our JavaScript API client, the client will cache each request in memory. So, if you type “apple”, then remove the “e”, instead of querying Algolia again (which would result in a sixth request), the client serves what it has in cache for “appl”.

Now, depending on the number of users you have and your Algolia plan, you may decide that as-you-type consumes too many units too quickly. In this case, you can debounce your search.

Were you initially referring to our Autocomplete library? If yes, you can debounce source execution to avoid querying Algolia at each keystroke. You no longer get the immediacy you have with as-you-type, but with a reasonable number, the experience remains pleasant and you control your unit consumption better.