使用 Tablestore Go SDK 更新多元索引生命周期,或在动态修改 Schema 时调整流量并切换索引。
前提条件
安装Tablestore Go SDK并初始化客户端。
功能说明
调用 UpdateSearchIndex 方法更新多元索引的生命周期。动态修改 Schema 时,还可使用该方法设置源索引和灰度索引的查询流量权重,或交换两个索引的指向。完整流程请参见动态修改 Schema。
func (client *tablestore.TableStoreClient) UpdateSearchIndex(request *tablestore.UpdateSearchIndexRequest) (*tablestore.UpdateSearchIndexResponse, error)ttl := int32(7 * 24 * 60 * 60)
_, err := client.UpdateSearchIndex(&tablestore.UpdateSearchIndexRequest{
TableName: "example_table",
IndexName: "example_index",
TimeToLive: &ttl,
})
if err != nil {
log.Fatal(err)
}参数说明
名称 | 类型 | 说明 |
TableName(必选) | string | 数据表名称。 |
IndexName(必选) | string | 要更新的多元索引名称。 |
TimeToLive(可选) | *int32 | 索引数据生命周期,单位为秒。取值为 -1 或不小于 86400 的 int32 整数,-1 表示数据永不过期。设置非 -1 值时,必须禁止通过 UpdateRow 更新数据,且索引生命周期不能超过数据表生命周期。更多信息请参见生命周期管理。 |
QueryFlowWeights(可选) | []*tablestore.QueryFlowWeight | 源索引和灰度索引的查询流量权重列表。各项 Weight 之和必须为 100。 |
SwitchIndexName(可选) | *string | 要与 IndexName 交换指向的灰度索引名称。 |
查询流量权重
名称 | 类型 | 说明 |
IndexName(必选) | string | 源索引或灰度索引名称。 |
Weight(必选) | int32 | 查询流量权重。 |
该文章对您有帮助吗?