创建多元索引后,使用ListSearchIndex接口可以获取当前实例下或某个数据表关联的所有多元索引的列表信息。

前提条件

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

参数

参数说明
TableName数据表名称,可以为空。
  • 如果设置了数据表名称,则返回该数据表关联的所有多元索引的列表。
  • 如果未设置数据表名称,则返回当前实例下所有多元索引的列表。

示例

func ListSearchIndex(client *tablestore.TableStoreClient, tableName string) {
    request := &tablestore.ListSearchIndexRequest{}
    request.TableName = tableName //设置数据表名称。
    resp, err := client.ListSearchIndex(request) //获取数据表关联的所有多元索引。
    if err != nil {
        fmt.Println("error: ", err)
        return
    }
    for _, info := range resp.IndexInfo {
        fmt.Printf("%#v\n", info) //打印多元索引的信息。
    }
    fmt.Println("ListSearchIndex finished, requestId:", resp.ResponseInfo.RequestId)
}