Framework integration
/
Rails
/
Advanced
Nov. 20, 2023
Advanced usage
Sometimes it can be necessary to access the Algolia API client or the model indices directly.
Access the Algolia API client# A
The client is available as a singleton and uses the Algolia credentials you added to your Rails configuration.
For example, to create a new API key:
Copy
1
key = AlgoliaSearch.client.add_api_key({ acl: ['search'], 'indexes': ['*_development', '*_development.tmp'] })
Access model indices# A
To access the index used by a model,
use the index
class method.
This method follows your naming configuration, such as per-environment settings or custom names.
Copy
1
2
index = Contact.index
# index.get_settings, index.partial_update_object, ...
Did you find this page helpful?