Skip to main content
To create a search experience for your app, you can choose between frontend or backend search. Use Algolia’s UI libraries, InstantSearch and Autocomplete, for client-side searching. Search requests are made from the browser or app, and results are returned without going through your server. This ensures rapid searching. For more information, see: Sometimes, backend search can be more suitable. The search request goes from your server to Algolia. Algolia sends the response back to your server, where you can process it.

Backend search response

With backend search, you’ll get ORM-compliant Rails model objects.
Ruby
The search method accepts a query and search parameters:
Ruby
If you always pass the same parameters, set them as index settings.
Ruby
Every ORM object of the response contains the highlighted text for the search query. This corresponds to the highlight_result attribute in Algolia’s raw response.
Ruby

Raw search response

To access attributes from the Algolia search response, use the raw_answer object:
Ruby
If you don’t need models, you can avoid loading objects from the database by retrieving Algolia’s raw JSON response:
Ruby

Search in specific indices

To search in specific indices, specify the with the index key:
Ruby
To search in a replica index, use the replica key:
Ruby

Backend pagination

To add pagination server-side, use one of the following pagination backends: To use :will_paginatem :kamari or :pagy, pass one of them as :pagination_backend option to your global configuration:
Ruby
In your controller:
Ruby
In your views:
ERB

Facets

To retrieve facets, you must first configure them. To retrieve them, use the facets method.
Ruby
Or perform a raw search and access the JSON response attributes:
Ruby

Search for facet values

If you have more facet values than what can fit in your UI, it can be helpful to let users search for them. If you want to support searching for facet values, configure the facet as searchable.
Ruby
This method accepts search parameters, such as filters.
Ruby
Last modified on June 12, 2026