List index metadata
This Astra DB Serverless feature is 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. The Data API tables commands are available through HTTP and the clients. If you use a client, tables commands are available only in client versions 2.0-preview or later. For more information, see Data API client upgrade guide. |
Gets information about the indexes associated with a specific table.
Method signature
-
Python
-
TypeScript
-
Java
-
curl
The following method belongs to the astrapy.table.Table
class.
list_indexes(
*,
table_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
) -> list[TableIndexDescriptor]
The following method belongs to the Table
class.
async listIndexes(
options?: {
nameOnly?: boolean,
timeout?: number | TimeoutDescriptor,
}
): TableIndexDescriptor[]
The following methods belong to the com.datastax.astra.client.tables.Table
class.
List<TableIndexDescriptor> listIndexes()
List<TableIndexDescriptor> listIndexes(ListIndexesOptions options)
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": true
}
}
}'
Result
-
Python
-
TypeScript
-
Java
-
curl
Returns an unordered list of TableIndexDescriptor
objects that describe each index in the table.
Example response:
[
TableIndexDescriptor(
name='m_vector_index',
definition=TableVectorIndexDefinition(
m_vector,
options=TableVectorIndexOptions(metric=dot_product, source_model=other)
)
),
TableIndexDescriptor(
name='winner_index',
definition=TableIndexDefinition(
winner,
options=TableIndexOptions(
ascii=False, normalize=True, case_sensitive=False
)
)
),
TableIndexDescriptor(
name='score_index',
definition=TableIndexDefinition(
score,
options=TableIndexOptions()
)
)
]
Returns a promise that resolves to an unordered list of TableIndexDescriptor
objects that describe each index in the table.
Example resolved response:
[
{
name: 'score_idx',
definition: {
column: 'score',
options: {}
}
}, {
name: 'winner_idx',
definition: {
column: 'winner',
options: { ascii: false, caseSensitive: false, normalize: true }
}
}, {
name: 'm_vector_idx',
definition: {
column: 'UNKNOWN',
apiSupport: {
createIndex: false,
filter: false,
cqlDefinition: 'CREATE CUSTOM INDEX m_vector_idx ON default_keyspace.games ("mVector")\n' +
"USING 'StorageAttachedIndex'\n" +
'WITH OPTIONS = {\n' +
" 'similarity_function' : 'DOT_PRODUCT',\n" +
" 'source_model' : 'OTHER'}"
}
}
}
]
Returns an unordered list of TableIndexDescriptor
objects that describe each index in the table.
The status.indexes
field in the response describes each index in the table.
Example response:
{
"status": {
"indexes": [
"titleIndex",
"authorIndex"
]
}
}
Parameters
-
Python
-
TypeScript
-
Java
-
curl
Name | Type | Summary |
---|---|---|
|
|
A timeout, in milliseconds, to impose on the underlying API request.
If not provided, the |
Name | Type | Summary |
---|---|---|
|
|
The options for this operation |
Options (ListIndexOptions
):
Name | Type | Summary |
---|---|---|
|
|
If false or undefined, the response includes index names and metadata. If true, the response includes only index names. |
|
|
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 index metadata for a table.
List index metadata
-
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 metadata
result = table.list_indexes()
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 metadata
(async function () {
const result = await table.listIndexes();
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 com.datastax.astra.client.tables.definition.indexes.TableIndexDescriptor;
import java.util.List;
public class CreateIndex {
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 metadata
List<TableIndexDescriptor> result = table.listIndexes();
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": true
}
}
}'
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.