查询多元索引信息

更新时间:
复制 MD 格式

使用 Python SDK 查询多元索引的字段、索引配置、生命周期和数据同步状态。

前提条件

安装Tablestore Python SDK并初始化客户端。

功能说明

调用 describe_search_index 方法查询指定多元索引的配置和数据同步状态。

def describe_search_index(
    self,
    table_name,
    index_name,
    include_sync_stat=True,
)

以下示例查询 example_tableexample_index 的信息,并输出生命周期、索引字段和数据同步阶段。

index_meta, sync_stat = client.describe_search_index(
    "example_table",
    "example_index",
)

print(index_meta.time_to_live)
for field_schema in index_meta.fields:
    print(field_schema.field_name)

if sync_stat is not None:
    print(sync_stat.sync_phase)

参数说明

describe_search_index 方法包含以下参数。

名称

类型

说明

table_name(必选)

str

数据表名称。

index_name(必选)

str

多元索引名称。

include_sync_stat(可选)

bool

是否返回数据同步状态,默认值为 True。设置为 False 时,返回值中的 sync_statNone

返回值

describe_search_index 方法返回一个元组,包含以下信息。

字段

类型

说明

index_meta

SearchIndexMeta

多元索引的字段、索引设置、预排序设置和生命周期。

sync_stat

SyncStat

数据同步状态。include_sync_statFalse 时,该字段为 None

索引元数据

index_meta 的类型为 SearchIndexMeta,包含以下字段。

字段

类型

说明

fields

List[FieldSchema]

索引字段列表。对象结构请参见创建多元索引

index_setting

IndexSetting

索引设置。

index_sort

Sort

预排序设置。

time_to_live

int

索引数据的生命周期,单位为秒。-1 表示数据永不过期。

数据同步状态

sync_stat 的类型为 SyncStat,包含以下字段。

字段

类型

说明

sync_phase

SyncPhase

数据同步阶段。FULL 表示全量同步,INCR 表示增量同步。

current_sync_timestamp

int

当前数据同步时间戳。