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 OTSClient instance 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 table. For more information, see Create search indexes.

Parameters

Parameter Description
TableName The name of the table.
IndexName The 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)
}