All Products
Search
Document Center

Tablestore:Query the description of a search index

Last Updated:Jul 31, 2024

After you create a search index for a data table, you can call the DescribeSearchIndex operation to query the description of the search index, including the fields and configurations of the search index.

Prerequisites

Parameters

Parameter

Description

TableName

The name of the data table.

IndexName

The name of the search index.

Examples

The following sample code provides an example on how to query the details of a search index, such as the time to live (TTL), creation time, synchronization status, and field information:

func DescribeSearchIndex(client *tablestore.TableStoreClient, tableName string, indexName string) {
    request := &tablestore.DescribeSearchIndexRequest{}
    request.TableName = tableName  // Specify the name of the data table. 
    request.IndexName = indexName  // Specify the name of the search index. 
    resp, err := client.DescribeSearchIndex(request)
    if err != nil {
        fmt.Println("error: ", err)
        return
    }
    fmt.Println("FieldSchemas:")
    for _, schema := range resp.Schema.FieldSchemas {
        fmt.Printf("%s\n", schema) // Display the schema information about the fields in the search index. 
    }
    fmt.Println("DescribeSearchIndex finished, requestId: ", resp.ResponseInfo.RequestId)
}

References

If an existing search index no longer meets your requirements, you can create a new search index, modify the schema of the existing search index to add, delete, or modify index fields, or adjust the TTL configuration of the search index. For more information, see Create a search index, Dynamically modify the schema of a search index, and TTL of search indexes.