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

Prerequisites

  • The TableStoreClient is initialized. For more information, see Initialization.
  • A data table is created. Data is written to the table.
  • A search index is created for the data table. For more information, see Create search indexes.

Parameters

ParameterDescription
TableNameThe name of the table.
IndexNameThe name of the search index.

Examples

func DescribeSearchIndex(client *tablestore.TableStoreClient, tableName string, indexName string) {
    request := &tablestore.DescribeSearchIndexRequest{}
    request.TableName = tableName  // Set the name of the table.
    request.IndexName = indexName  // Set 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 of the fields in the search index.
    }
    fmt.Println("DescribeSearchIndex finished, requestId: ", resp.ResponseInfo.RequestId)
}