文档

查询多元索引描述信息

更新时间:

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

前提条件

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

参数

参数

说明

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)
}

相关文档

如果已有多元索引不满足使用需求,您可以创建新的多元索引、通过修改多元索引的Schema来增删改多元索引字段或者根据需要调整多元索引的TTL。具体操作,请参见创建多元索引动态修改schema生命周期管理