使用 Tablestore Go SDK 查询多元索引的结构、同步状态、计量信息和生命周期。
前提条件
安装Tablestore Go SDK并初始化客户端。
功能说明
调用 DescribeSearchIndex 方法查询指定多元索引的结构和运行信息。将 IncludeSyncStat 设置为 true 可返回数据同步状态。
func (client *tablestore.TableStoreClient) DescribeSearchIndex(request *tablestore.DescribeSearchIndexRequest) (*tablestore.DescribeSearchIndexResponse, error)response, err := client.DescribeSearchIndex(&tablestore.DescribeSearchIndexRequest{
TableName: "example_table",
IndexName: "example_index",
IncludeSyncStat: proto.Bool(true),
})
if err != nil {
log.Fatal(err)
}
fmt.Println(response.Schema)
fmt.Println(response.SyncStat)
fmt.Println(response.TimeToLive)参数说明
名称 | 类型 | 说明 |
TableName(必选) | string | 数据表名称。 |
IndexName(必选) | string | 多元索引名称。 |
IncludeSyncStat(可选) | *bool | 是否返回数据同步状态,默认值为 false。 |
返回值
名称 | 类型 | 说明 |
Schema | *tablestore.IndexSchema | 多元索引结构。 |
SyncStat | *tablestore.SyncStat | 数据同步状态。SyncPhase 为 FULL 表示全量同步,为 INCR 表示已进入增量同步。 |
MeteringInfo | *tablestore.MeteringInfo | 索引存储量、行数、预留读 CU 和统计更新时间。 |
QueryFlowWeights | []*tablestore.QueryFlowWeight | 动态修改 Schema 期间各索引的查询流量权重。 |
CreateTime | int64 | 索引创建时间。 |
TimeToLive | int32 | 索引数据生命周期,单位为秒。 |
该文章对您有帮助吗?