List index names
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. |
Gets the names of the indexes for a table.
Method signature
-
Python
-
TypeScript
-
Java
-
curl
The following method belongs to the astrapy.Table
class.
list_index_names(
*,
table_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
) -> list[str]
async listIndexes(
options?: ListIndexOptions & {
nameOnly: true,
timeout?: number | TimeoutDescriptor,
}
): TableIndexDescriptor[]
The following methods belong to the com.datastax.astra.client.tables.Table
class.
List<String> listIndexesNames()
List<String> listIndexesNames(ListIndexesOptions listIndexesOptions)
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 '{
"listIndexes": {
"options": {
"explain": false
}
}
}'
Result
-
Python
-
TypeScript
-
Java
-
curl
Returns the index names for a table as an unordered list of strings.
Example response:
['m_vector_index', 'winner_index', 'score_index']
Returns a promise that resolves to the index names for a table as an unordered list of strings.
Example resolved response:
['score_idx', 'winner_idx', 'm_vector_idx']
Returns the index names for a table as an unordered list of strings.
Returns the index names for a table as an unordered list of strings in the status.indexes
field of the response.
Example response:
{
"status": {
"indexes": [
"index_name_1",
"index_name_2"
]
}
}
Parameters
-
Python
-
TypeScript
-
Java
-
curl
Name | Type | Summary |
---|---|---|
|
|
A timeout, in milliseconds, to impose on the underlying API request. If not provided, the Table defaults apply. This parameter is aliased as |
Name | Type | Summary |
---|---|---|
|
|
The options for this operation |
Options (ListIndexOptions
):
Name | Type | Summary |
---|---|---|
|
|
If true, the response includes only index names. If false or undefined, the response includes index names and metadata. |
|
|
The client-side timeout for this operation. |
Name | Type | Summary |
---|---|---|
|
Specialization of index creation options. |
Name | Type | Summary |
---|---|---|
|
|
The Data API command to get a list of indexes associated with a table in a Serverless (Vector) database. |
|
|
If true, the response includes index names and metadata. If false or unset, the response includes only index names. |
Examples
The following examples demonstrate how to get the names of the indexes for a table.
List index names
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
# Get an existing table
client = DataAPIClient("ASTRA_DB_APPLICATION_TOKEN")
database = client.get_database("ASTRA_DB_API_ENDPOINT")
table = database.get_table("TABLE_NAME")
# List index names
result = table.list_index_names()
print(result)
import { DataAPIClient } from '@datastax/astra-db-ts';
// Get an existing table
const client = new DataAPIClient('ASTRA_DB_APPLICATION_TOKEN');
const database = client.db('ASTRA_DB_API_ENDPOINT');
const table = database.table('TABLE_NAME');
// List index names
(async function () {
const result = await table.listIndexes({ nameOnly: true });
console.log(result);
})();
package com.example;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.definition.rows.Row;
import java.util.List;
public class ListIndexNames {
public static void main(String[] args) {
// Get an existing table
Table<Row> table = new DataAPIClient("ASTRA_DB_APPLICATION_TOKEN")
.getDatabase("ASTRA_DB_API_ENDPOINT")
.getTable("TABLE_NAME");
// List index names
List<String> result = table.listIndexesNames();
System.out.println(result);
}
}
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 '{
"listIndexes": {
"options": {
"explain": false
}
}
}'
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.