Delete Index
deleteIndex
ACL
$index->delete()
About this method
We released a new version of the PHP API client in public beta. Read the beta documentation for more information.
We released a new version of the JavaScript API client in public beta. Read the beta documentation for more information.
We released a new version of the Java API client in public beta. Read the beta documentation for more information.
You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.
You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.
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 need to 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
Read the Algolia CLI documentation for more information.
To see a complete app, including all import and setup instructions, go to Install the .NET API client.
To see a complete app, including all import and setup instructions, go to Install the Go API client.
To see a complete app, including all import and setup instructions, go to Install the Java API client.
To see a complete app, including all import and setup instructions, go to Install the Kotlin API client.
To see a complete app, including all import and setup instructions, go to Install the Scala API client.
To see a complete app, including all import and setup instructions, go to Install the Swift API client.
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(
'YourApplicationID', 'YourAPIKey'
);
$index = $client->initIndex('indexName');
$index->delete();
Delete multiple indices
The Algolia CLI lets you delete multiple primary indices at the same time.
1
algolia indices delete <indexName_1> <indexName_2> <indexName_3>
Parameters
indexName
|
type: string
Required
Name of the index to be deleted. |
Response
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
1
2
3
4
{
"deletedAt": "2017-12-18T21:22:40.761Z",
"taskID": 19541511530
}
deletedAt
|
string
Date at which the job to delete the index has been created. |
taskID
|
integer
This is the taskID which is used with the |