FAQ / Searching / Searching from the front-end or the back-end? What do you recommend?
Jul. 26, 2019

Searching from the front-end or the back-end? What do you recommend?

Speed. A front-end implementation will hit our servers directly, without going through your backend. It can be up to 10x faster for the end-user to retrieve the results.

DSN. We have a distributed API allowing you to select multiple datacenters around the world. This allows your users to target the closest server, which has a huge impact on latency. This can only work with a front-end implementation.

Availability. With a back end implementation, you force some network routes. Even if there is only a local problem in the network, all of your users will be affected. Having a front-end implementation means only a subset of your users will be affected if there’s a network problem.

What type of user experience you create is entirely flexible - Algolia can power a wide array of potential search patterns. The response returned when you query Algolia is JSON, which allows you to easily consume the search results programmatically and craft any type of experience. The response contains a breadth of useful information, even just beyond the basic matching results: total number of matches, pagination, computed facets, highlighting, and more.

All of this can be done directly on the client machine, using JavaScript. With this approach, your JavaScript communicates directly with our servers, bypassing yours. In other words, your JavaScript will build the UI components, capture user input, contact our servers, and display the results. This is what we mean by frontend search.

Take a look at here for more detail, including code samples and a live demo.

So, while your server remains responsible for many Algolia-related activities - like importing and updating data, configuring indices, monitoring your users’ activities, etc. - it will not need to get involved in the search experience. The benefits of this are many, as enumerated above.

If you feel like a back-end implementation would work better in your case, don’t hesitate to get in touch with us.

Did you find this page helpful?