Drop an index
Tables with the Data API are currently in public preview. Development is ongoing, and the features and functionality are subject to change. Astra DB Serverless, and the use of such, is subject to the DataStax Preview Terms. |
Deletes an index from a table in a Serverless (Vector) database.
Method signature
-
Python
-
TypeScript
-
Java
-
curl
The following method belongs to the astrapy.Database
class.
drop_table_index(
name: str,
*,
keyspace: str,
if_exists: bool,
table_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
) -> None
The following method belongs to the Db
class.
async dropTableIndex(
name: string,
options?: {
ifExists?: boolean,
timeout?: number | TimeoutDescriptor,
keyspace?: string,
}
): void
The following methods belong to the com.datastax.astra.client.databases.Database
class.
void dropTableIndex(String indexName)
void dropTableIndex(
String indexName,
DropTableIndexOptions dropIndexOptions
)
curl -sS -L -X POST "ASTRA_DB_API_ENDPOINT/api/json/v1/ASTRA_DB_KEYSPACE" \
--header "Token: ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dropIndex": {
"name": "INDEX_NAME"
}
}'
Result
-
Python
-
TypeScript
-
Java
-
curl
Deletes the specified index.
Does not return anything.
Deletes the specified index.
Returns a promise that resolves once the operation completes.
Deletes the specified index.
Does not return anything.
Deletes the specified index from the a table.
If the command succeeds, the response indicates the success.
Example response:
{
"status": {
"ok": 1
}
}
Parameters
-
Python
-
TypeScript
-
Java
-
curl
Name | Type | Summary |
---|---|---|
|
|
The name of the index to delete. |
|
|
The keyspace where you created the index. If unspecified, the database’s default keyspace setting is used. |
|
|
If If |
|
|
A timeout, in milliseconds, to impose on the underlying API request.
If not provided, the |
Name | Type | Summary |
---|---|---|
|
|
The name of the index to delete. |
|
|
The options for this operation. |
Options (TableDropIndexOptions
):
Name | Type | Summary |
---|---|---|
|
|
If If |
|
|
The client-side timeout for this operation. |
Name | Type | Summary |
---|---|---|
|
|
Name of the index to drop |
|
Specialization of index deletion options, including If If |
Name | Type | Summary |
---|---|---|
|
|
The Data API command to delete an index from a Serverless (Vector) database. It acts as a container for all the attributes and settings required to delete the index. |
|
|
The name of the index to delete. |
Examples
The following examples demonstrate how to drop an index from a table.
Drop an index
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get a database
client = DataAPIClient("ASTRA_DB_APPLICATION_TOKEN")
database = client.get_database("ASTRA_DB_API_ENDPOINT")
# Drop an index
database.drop_table_index("rating")
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get a database
const client = new DataAPIClient('ASTRA_DB_APPLICATION_TOKEN');
const database = client.db('ASTRA_DB_API_ENDPOINT');
// Drop an index
(async function () {
await database.dropTableIndex("rating");
})();
package com.example;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;
import java.util.List;
public class DropIndex {
public static void main(String[] args) {
// Get a database
Database database = new DataAPIClient("ASTRA_DB_APPLICATION_TOKEN")
.getDatabase("ASTRA_DB_API_ENDPOINT");
// Drop an index
database.dropTableIndex("rating");
}
}
curl -sS -L -X POST "ASTRA_DB_API_ENDPOINT/api/json/v1/ASTRA_DB_KEYSPACE/ASTRA_DB_TABLE" \
--header "Token: ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"dropIndex": {
"name": "rating"
}
}'
Drop an index only if the index exists
Use this option to silently do nothing if an index with the specified name does not exist.
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get a database
client = DataAPIClient("ASTRA_DB_APPLICATION_TOKEN")
database = client.get_database("ASTRA_DB_API_ENDPOINT")
# Drop an index
database.drop_table_index("rating", if_exists=True)
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get a database
const client = new DataAPIClient('ASTRA_DB_APPLICATION_TOKEN');
const database = client.db('ASTRA_DB_API_ENDPOINT');
// Drop an index
(async function () {
await database.dropTableIndex("rating", { ifExists: true });
})();
package com.example;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.tables.commands.options.DropTableIndexOptions;
import java.util.List;
public class DropIndex {
public static void main(String[] args) {
// Get a database
Database database = new DataAPIClient("ASTRA_DB_APPLICATION_TOKEN")
.getDatabase("ASTRA_DB_API_ENDPOINT");
// Drop an index
DropTableIndexOptions options = new DropTableIndexOptions()
.ifExists(true);
database.dropTableIndex("rating", options);
}
}
This option has no literal equivalent in HTTP. Instead, you can list the index names to see if an index with the name already exists.
Client reference
-
Python
-
TypeScript
-
Java
-
curl
For more information, see the client reference.
For more information, see the client reference.
For more information, see the client reference.
Client reference documentation is not applicable for HTTP.