使用 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 | 索引資料生命週期,單位為秒。 |