创建多元索引后,使用DescribeSearchIndex接口可以查询多元索引的描述信息,包括多元索引的字段信息和索引配置等。

前提条件

  • 已初始化Client。具体操作,请参见初始化
  • 已创建数据表并写入数据。
  • 已在数据表上创建多元索引。具体操作,请参见创建多元索引

参数

参数说明
TableName数据表名称。
IndexName多元索引名称。

示例

func DescribeSearchIndex(client *tablestore.TableStoreClient, tableName string, indexName string) {
    request := &tablestore.DescribeSearchIndexRequest{}
    request.TableName = tableName  //设置数据表名称。
    request.IndexName = indexName  //设置多元索引名称。
    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) //打印多元索引中字段的schema信息。
    }
    fmt.Println("DescribeSearchIndex finished, requestId: ", resp.ResponseInfo.RequestId)
}