List index metadata (Go)

Gets information about the indexes associated with a specific table.

Ready to write code? See the examples for this method to get started. If you are new to the Data API, check out the quickstart.

Result

Returns an unordered slice of IndexDescriptor structs that describe each index in the table.

Parameters

Use the ListIndexes method, which belongs to the Table type.

Method signature
func (t *Table) ListIndexes(
  ctx context.Context,
  opts ...options.ListIndexesOption
) ([]results.IndexDescriptor, error)
Name Type Summary

ctx

context.Context

The context for the operation.

opts

…​options.ListIndexesOption

Optional. A builder to generate options for this operation. See Methods of the ListIndexesOption builder for more details.

Methods of the ListIndexesOption builder
Method Summary

UpdateAPIOptions(v …​APIOption)

Optional. General API options for this operation, including the timeout.

Examples

The following examples demonstrate how to get index metadata for a table.

List index metadata

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"

	"github.com/datastax/astra-db-go/v2/astra"
	"github.com/datastax/astra-db-go/v2/astra/options"
)

func main() {
	ctx := context.Background()

	// Get an existing table
	client := astra.NewClient(
		options.API().SetEnvironment(options.EnvironmentHCD),
	)

	database := client.Database(
		"API_ENDPOINT",
		options.API().
			SetUsernamePasswordTokenProvider(
				"USERNAME",
				"PASSWORD",
			).
			SetKeyspace("KEYSPACE_NAME"),
	)

	table := database.Table("TABLE_NAME")

	// List index metadata
	indexes, err := table.ListIndexes(ctx)

	if err != nil {
		log.Fatal(err)
	}

	output, err := json.Marshal(indexes)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(output))
}

Client reference

For more information, see the client reference.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | 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: Contact IBM