Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Algolia – Powerful hosted search engine

Wednesday, June 7th, 2017 by Servage

algoliaHave you ever searched for something on a website without being able to find what you are looking for? Very likely. Implementing a powerful search engine for a website can be both difficult to make and resource intensive to use. A hosted search engine called Algolia aims to make this easier by moving the whole search process to their cloud-based search engine.

What is Algolia?

Algolia is a hosted text-based search engine for a predefined dataset. This means you as a developer send some data, for example a collection of books, to Algolia for indexing. You can index those books by their title, author, description and many more fields. When a user searches for a book on your website, you submit an API call to Algolia, which does all the processing of that search query and returns the results back to your website.

Algolia has a free community plan that allows you to index up to 10.000 records and make up to 100.000 searches against their search engine per month. What makes Algolia special is the speed of their service. The speed is achieved with a global distributed search network, which acts like a CDN (content delivery network). To try out the performance yourself, you can try their demo at www.algolia.com.

A Technical Overview

Algolia supports many programming languages and frameworks out of the box. Whatever language or framework you choose, you start by including a dependency in your project. You can then create an instance of the Algolia client and call its methods. Indexing data in Algolia works by sending an array of JSON objects to the client. The same client has a method for searching data by providing it with a search keyword as a string.

If you want a more sophisticated way and more control over your search indexes, you can for example use the Laravel Scout feature to tell Algolia which properties of your models should be indexed and searchable.

The Data Flow of a Search

To implement an Algolia-powered search on your website, the first thing you need is a search field. Algolia has an official tutorial for implementing an advanced search field with real-time dropdown results on their website. Alternatively, you can build one from scratch if you prefer that approach.

No matter what path you take, you have to detect what the user has typed in a search field. If you are using JavaScript and PHP in your project, it would be a perfect time to use some AJAX or other types of asynchronous JavaScript, such as HTTP requests using React or Angular. You can take the value of the search field, send it to your PHP back end, which in turns calls the search method of the Algolia client. Algolia returns some relevant search results back to your back end, which you can then pass back to the front end. In a scenario like this, you can also do the searching directly on the front end without going through the back end at all if you prefer it that way.

More information on how to implement a real-time search like this can be found in the documentation at www.algolia.com.

Algolia - Powerful hosted search engine, 5.0 out of 5 based on 1 rating
Categories: Software & Webapps

Keywords:

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.