Framework integration / Rails / Advanced

Sometimes it can be necessary to access the Algolia API client directly.

Access the Algolia API client

The client is available as a singleton and uses the Algolia credentials you added to your Rails configuration.

For example, to get an index’s settings:

1
key = AlgoliaSearch.client.get_settings("index_name")

Access model indices

To access the index used by a model, use the index_name class method and pass it as a variable to the API client. This method follows your naming configuration, such as per-environment settings or custom names.

1
2
index_name = Contact.index_name
# client..get_settings(index_name), ...
Did you find this page helpful?