API Reference / API Methods / Manage indices / Index exists
Required API Key: any key with the settings ACL
Method signature
$index->exists()

About this method # A

Returns whether an index exists or not.

Algolia lets you instantiate indices with any name, even if they haven’t been previously created. An initialized index is created when you call save objects or set settings on it. This can result in the accidental creation of new indices, or modification of existing ones.

The exists method returns a boolean that indicates whether an initialized index has been created.

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 # A

Check if an index exists#

1
$index->exists();

Parameters # A

No parameters for this method.

Response # A

This section shows the JSON response returned by the API. Since each language encapsulates this response inside objects specific to that language and/or implementation, the actual type in your language might differ from what’s written here. You can view the response in the logs (using the getLogs method).

JSON format#

This method returns true if the index exists, and false otherwise.

Did you find this page helpful?
PHP v3