API client / Methods / Manage indices
Required API Key: any key with the deleteIndex ACL
Method signature
$index->delete()

We released a new version of the PHP API client in public beta. Read the beta documentation for more information.

About this method # A

Delete an index and all its settings, including links to its replicas.

Deleting an index doesn’t affect its analytics data.

If you try to delete a nonexistent index, the engine ignores the operation but doesn’t send back an error.

Deleting indices with replicas#

When deleting an index with replicas, the replicas become independent indices.

You can’t delete a replica index directly. First, you must unlink it to turn it into a regular index. Then you can delete it.

Deleting only records#

To only remove records from the index, use the clearObjects method. This preserves the index’s settings, Rules, and Synonyms.

Deleting multiple indices#

To delete more than one index, see Delete multiple indices.

Examples # A

Delete an index by name#

1
2
3
4
5
6
7
8
9
10
<?php
require_once __DIR__."/vendor/autoload.php";
use Algolia\AlgoliaSearch\SearchClient;

// Use an API key with `deleteIndex` ACL
$client = SearchClient::create(
  'AJ0P3S7DWQ', 'YourAPIKey'
);
$index = $client->initIndex('YourIndexName');
$index->delete();

Parameters # A

Parameter Description
indexName #
type: string
Required

Name of the index to be deleted.

Response # A

This section shows the JSON response returned by the API. Each API client encapsulates this response inside objects specific to the programming language, so that the actual response might be different. You can view the response by using the getLogs method. Don’t rely on the order of attributes in the response, as JSON doesn’t guarantee the ordering of keys in objects.

JSON format#

1
2
3
4
{
  "deletedAt": "2017-12-18T21:22:40.761Z",
  "taskID": 19541511530
}
Field Description
deletedAt #
string

Date at which the job to delete the index has been created.

taskID #
integer

The taskID for the waitTask method.

Did you find this page helpful?
PHP v3