title: How to build an autocomplete API?
body: <p>I am trying to wrap my head around building a proper autocomplete functionality. I am practicing by building a really simple API that autocompletes users' names.</p>
  
  <p>Currently, I have a database that contains columns, <code>given_name</code> and <code>last_name</code>. They are indexed with elasticsearch. And, I have built an API that accepts a search term to query elasticsearch.</p>
  
  <p>I am concerned with how the frontend communicates with this API. The obvious way of doing it is to call the API after every keyup on the search input. However, this is a lot of requests being sent. Making calls after delays to reduce requests feels <em>hacky</em>. Is there an appropriate way of doing this?</p>
  
  <p>I have found many guides on how to build an elasticsearch API but nothing that puts frontends and backends together.</p>