Implementing Algolia can be broken down into a simple 3-step process:
- index your data with us
- configure any necessary relevance or ranking settings
- build a search user interface.
Algolia provides a JSON based REST API for indexing data. This means all data pushed to an Algolia index must be sent as JSON. To make indexing easier, API clients have been developed for most major languages. Additionally, if you would like to test a static subset of your data, you can upload a JSON file directly via our dashboard.
Indexing is not a one time thing. Once your initial data has been indexed, you will want to configure your application to sync your database changes such as additions, updates, and deletions with your indices in Algolia.
It is important when indexing your data to choose which fields should be included. You only want to index data needed for searching, displaying, filtering, and ranking. All other data points not needed for these cases should be excluded in order to keep your index optimized.
Algolia provides many ways to configure your index and fine-tune your overall index relevancy. The most important settings to configure are the searchable attributes and the custom ranking attributes. Beyond these, Algolia has pre-set many sensible defaults that should work for most use cases. However, you may find your data set requires further configuration tweaking.
The searchable attributes field controls which record attributes can be found by querying. It should be noted that the order of this setting matters - attributes at the top of the list are considered more important.
Custom Ranking Attributes
Algolia’s default ranking includes a custom ranking field which allows you to add business metrics to the relevance calculation. This means you can leverage any numerical or boolean attributes in your data to impart additional relevancy rules. For example, you might consider adding availability or popularity information to ensure in stock and popular items are ranked highest.
Creating a Search Experience
Once your data has been indexed and your indices properly configured, the final step is to implement search within your site or application.
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.
Searches performed on Algolia indices consist of a full-text query along with zero or more optional parameters. Optional parameters can be used to override configured settings so you can change the behavior of specific searches while not impacting others. For example, you might choose to retrieve more results for certain queries, but limit this number otherwise.
We highly recommend issuing all search requests directly from the end user’s browser, mobile device, or client. It will reduce the overall search latency, and thus allow you to provide an instant “find as you type” experience to your users - offloading your servers at the same time.