Index Exists
settings
ACL
$index->exists()
About this method
Returns whether an index exists or not.
This method returns a boolean that tells whether an initialized index exists or not.
Algolia lets you instantiate indices with any name, even if they don’t exist yet. In that case, they are created once you save objects or set settings on them. It can result in accidentally creating new indices, or modifying existing ones.
This method is useful to ensure you’re working either on a new or an existing index.
You should be careful when using this method to execute code conditionally. Due to the asynchronous nature of saving objects, the existence of an index may change between the time a condition is met, and when the conditional code executes. Be mindful of the surrounding code, and of any process that may be altering your indices.
Examples
Check if an index exists
1
$index->exists();
Parameters
No parameters for this method.
Response
No response