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.

listIndexes(
  options?: {
    nameOnly?: boolean,
    timeout?: number | TimeoutDescriptor,
  }
): Promise<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.

Parameters

  • Python

  • TypeScript

  • Java

  • curl

Name Type Summary

table_admin_timeout_ms

int | None

A timeout, in milliseconds, to impose on the underlying API request. If not provided, the Table defaults apply. This parameter is aliased as request_timeout_ms and timeout_ms for convenience.

Name Type Summary

option?

ListIndexOptions

The options for this operation

Options (ListIndexOptions):

Name Type Summary

nameOnly?

boolean

If false or undefined, the response includes index names and metadata. If true, the response includes only index names.

timeout?

number | TimeoutDescriptor

The client-side timeout for this operation.

Name Type Summary

options

ListIndexesOptions

Specialization of index creation options.

Name Type Summary

listIndexes

command

The Data API command to get a list of indexes associated with a table in a Serverless (Vector) database.

options.explain

boolean

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.

  • Python

  • TypeScript

  • Java

  • curl

List the details of all indexes on a table:

my_table.list_indexes()

To get index names only, see List index metadata.

Example:

Full script
from astrapy import DataAPIClient
client = DataAPIClient("TOKEN")
database = client.get_database("API_ENDPOINT")

from astrapy.constants import SortMode
from astrapy.info import (
    CreateTableDefinition,
    ColumnType,
)

my_table = database.create_table(
    "games",
    definition=(
        CreateTableDefinition.builder()
        .add_column("match_id", ColumnType.TEXT)
        .add_column("round", ColumnType.TINYINT)
        .add_vector_column("m_vector", dimension=3)
        .add_column("score", ColumnType.INT)
        .add_column("when", ColumnType.TIMESTAMP)
        .add_column("winner", ColumnType.TEXT)
        .add_set_column("fighters", ColumnType.UUID)
        .add_partition_by(["match_id"])
        .add_partition_sort({"round": SortMode.ASCENDING})
        .build()
    ),
)

from astrapy.info import TableIndexOptions

my_table.create_index(
    "score_index",
    column="score",
)

my_table.create_index(
    "winner_index",
    column="winner",
    options=TableIndexOptions(
        ascii=False,
        normalize=True,
        case_sensitive=False,
    ),
)

from astrapy.constants import VectorMetric
from astrapy.info import TableVectorIndexOptions

my_table.create_vector_index(
    "m_vector_index",
    column="m_vector",
    options=TableVectorIndexOptions(
        metric=VectorMetric.DOT_PRODUCT,
    ),
)

indexes = my_table.list_indexes()
indexes
# [TableIndexDescriptor(name='m_vector_index', definition=... (shortened)
indexes[1].definition.column
# 'winner'
indexes[1].definition.options.case_sensitive
# False
indexes = my_table.list_indexes()
indexes
# [TableIndexDescriptor(name='m_vector_index', definition=... (shortened)
indexes[1].definition.column
# 'winner'
indexes[1].definition.options.case_sensitive
# False

List the details of all indexes on a table:

await table.listIndexes();

Example:

Full script
import { CreateTableDefinition, DataAPIClient, SomeRow } from '@datastax/astra-db-ts';

// Instantiate the client and connect to the database
const client = new DataAPIClient();
const db = client.db(process.env.CLIENT_DB_URL!, { token: process.env.CLIENT_DB_TOKEN! });

// Create table schema using bespoke Data API table definition syntax.
// For information about table definition and data types, see the documentation for createTable.
const TableDefinition = <const>{
  columns: {
    matchId: 'text'
    round: 'tinyint',
    mVector: { type: 'vector', dimension: 3 },
    score: 'int',
    when: 'timestamp',
    winner: 'text',
    fighters: { type: 'set', valueType: 'uuid' },
  },
  primaryKey: {
    partitionBy: ['matchId'],
    partitionSort: { round: 1 },
  },
} satisfies CreateTableDefinition;

(async function () {
    // Create an untyped table if a 'games' table doesn't already exist
  const table = await db.createTable<SomeRow>('games', { definition: TableDefinition, ifNotExists: true });

  // Create a secondary index on the 'score' column with default options.
  // Errors if a 'score_idx' index already exists in the working keyspace.
  await table.createIndex('score_idx', 'score');

  // Create a secondary index on the 'winner' column with case-insensitivity
  // Because 'ifNotExists: true', the command does not throw an error
  // if the working keyspace already has an index named 'winner_idx'.
  await table.createIndex('winner_idx', 'winner', {
    options: {
      caseSensitive: false,
    },
    ifNotExists: true,
  });

  // Case insensitive indexes ignore case when querying.
  // Insert a row with upper case and lower case characters,
  // and then query the row.
  // findOne returns a match because 'winner_idx' is case-insensitive.
  await table.insertOne({ matchId: '01', round: 0, winner: 'Gray Tist' });
  await table.findOne({ winner: 'gray tist' }).then(console.log);

  // Create a vector index on the 'mVector' column with cosine similarity (default).
  // Errors if an 'm_vector_idx' index already exists in the working keyspace.
  await table.createVectorIndex('m_vector_idx', 'mVector');

  // Create a vector index on the 'mVector' column with dot-product similarity.
  // Because 'ifNotExists: true', the command does not throw an error
  // if the working keyspace already has an index named 'm_vector_idx'.
  await table.createVectorIndex('m_vector_idx', 'mVector', {
    options: {
      metric: 'dot_product',
    },
    ifNotExists: true,
  });

  // Drop the index so you can recreate it with different options.
  await db.dropTableIndex('m_vector_idx');

  // Create the vector index with dot-product similarity and a source model.
  // For accurate searches, use a source model and metric that are compatible with your vectors.
  await table.createVectorIndex('m_vector_idx', 'mVector', {
    options: {
      metric: 'dot_product',
      sourceModel: 'ada002',
    },
  });

  // Vector indexes allow you to perform vector searches.
  // Insert a row with a vector, and then run a vector search on the table.
  await table.insertOne({ matchId: '01', round: 0, mVector: [0.2, -0.3, -0.5] });
  await table.findOne({}, { sort: { mVector: [0.2, -0.3, -0.5] } }).then(console.log);

  // Get detailed information about the indexes
  // Returns information like [{ name: 'score_idx', definition: { column: 'score', options: {} } }, ...]
  await table.listIndexes().then(console.log);

  // Get index names only.
  // Returns information like ['score_idx', 'winner_idx', 'm_vector_idx', ...]
  await table.listIndexes({ nameOnly: true }).then(console.log);

  // Drop an index from a database's working keyspace without checking if the index exists.
  // If there is no match, the command succeeds but does nothing.
  // If there is a match, the named index is deleted.
  await db.dropTableIndex('score_idx');

  // Drop an index from a database's working keyspace if the index exists.
  // Errors if there is no match.
  await db.dropTableIndex('score_idx', { ifExists: true });

  // Uncomment the following line to drop the table and any related indexes.
  // await table.drop();
})();
// Get detailed information about the indexes
// Returns information like [{ name: 'score_idx', definition: { column: 'score', options: {} } }, ...]
await table.listIndexes().then(console.log);

// Get index names only.
// Returns information like ['score_idx', 'winner_idx', 'm_vector_idx', ...]
await table.listIndexes({ nameOnly: true }).then(console.log);

List the details of all indexes on a table:

List<TableIndexDescriptor> indexes = tableGames.listIndexes();

List indexes with command options:

ListIndexesOptions options = new ListIndexesOptions()
  .timeout(Duration.ofSeconds(5));

tableGames
  .listIndexes(options)
  .forEach(idx -> {
      System.out.println(
        "Index: " + idx.getName() +
        " on column: " + idx.getDefinition().getColumn()
      );
   });

To get index names only, see List index names.

Example:

package com.datastax.astra.client.tables;

import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.core.vector.SimilarityMetric;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.tables.commands.options.CreateVectorIndexOptions;
import com.datastax.astra.client.tables.commands.options.ListIndexesOptions;
import com.datastax.astra.client.tables.definition.indexes.TableIndexDefinition;
import com.datastax.astra.client.tables.definition.indexes.TableIndexDefinitionOptions;
import com.datastax.astra.client.tables.definition.indexes.TableIndexDescriptor;
import com.datastax.astra.client.tables.definition.indexes.TableVectorIndexDefinition;
import com.datastax.astra.client.tables.definition.rows.Row;

import java.time.Duration;
import java.util.List;

public class ListIndexes {
 public static void main(String[] args) {
   Database db = new DataAPIClient("token").getDatabase("endpoint");
   Table<Row> tableGames = db.getTable("games");

   //List<TableIndexDescriptor> indexes = tableGames.listIndexes();

   ListIndexesOptions options = new ListIndexesOptions()
     .timeout(Duration.ofSeconds(5));

   tableGames.listIndexes(options).forEach(idx -> {
        System.out.println("Index: " + idx.getName() + " on column: " + idx.getDefinition().getColumn());
   });
 }
}

Get details about indexes associated with a specific table:

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
    }
  }
}' | jq

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.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax | Privacy policy | Terms of use | Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com