Frontend 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:- What is InstantSearch?
- What is Autocomplete?
- Example Rails app with Autocomplete and InstantSearch.js
Backend search
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
search
method accepts a query and search parameters:
Ruby
Ruby
highlight_result
attribute in Algolia’s raw response.
Ruby
Raw search response
To access attributes from the Algolia search response, use theraw_answer
object:
Ruby
Ruby
Search in specific indices
To search in specific indices, specify the index with theindex
key:
Ruby
replica
key:
Ruby
Backend pagination
To add pagination server-side, use one of the following pagination backends: To use:will_paginate
m :kamari
or :pagy
,
pass one of them as :pagination_backend
option to your global configuration:
Ruby
Ruby
ERB
Facets
To retrieve facets, you must first configure them. To retrieve them, use thefacets
method.
Ruby
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 assearchable
.
Ruby
Ruby