使用 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 |
|
當前資料同步時間戳記。 |