使用 Python SDK 查询多元索引的字段、索引配置、生命周期和数据同步状态。
前提条件
安装Tablestore Python SDK并初始化客户端。
功能说明
调用 describe_search_index 方法查询指定多元索引的配置和数据同步状态。
def describe_search_index(
self,
table_name,
index_name,
include_sync_stat=True,
)
以下示例查询 example_table 中 example_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(必选) |
|
数据表名称。 |
|
index_name(必选) |
|
多元索引名称。 |
|
include_sync_stat(可选) |
|
是否返回数据同步状态,默认值为 |
返回值
describe_search_index 方法返回一个元组,包含以下信息。
|
字段 |
类型 |
说明 |
|
index_meta |
|
多元索引的字段、索引设置、预排序设置和生命周期。 |
|
sync_stat |
|
数据同步状态。 |
索引元数据
index_meta 的类型为 SearchIndexMeta,包含以下字段。
|
字段 |
类型 |
说明 |
|
fields |
|
索引字段列表。对象结构请参见创建多元索引。 |
|
index_setting |
|
索引设置。 |
|
index_sort |
|
预排序设置。 |
|
time_to_live |
|
索引数据的生命周期,单位为秒。 |
数据同步状态
sync_stat 的类型为 SyncStat,包含以下字段。
|
字段 |
类型 |
说明 |
|
sync_phase |
|
数据同步阶段。 |
|
current_sync_timestamp |
|
当前数据同步时间戳。 |