All Products
Search
Document Center

Tablestore:Update search index configurations

Last Updated:Aug 06, 2026

Use Tablestore SDK for Python to update the TTL of a search index.

Prerequisites

Description

Call update_search_index to update the TTL of a search index.

def update_search_index(
    self,
    table_name,
    index_name,
    index_meta,
)
Important

Take note of the following items when you configure a TTL:

  • The update_search_index method in Tablestore SDK for Python can update only the TTL. It cannot modify index fields, index settings, or presorting settings.

  • The TTLs of a table and a search index are independent, but the search index TTL cannot exceed the table TTL. To increase the search index TTL beyond the current table TTL, increase the table TTL first. To decrease the table TTL below the current search index TTL, decrease the search index TTL first.

  • Tablestore deletes expired search index data once a day. Expired data may remain queryable until the next deletion cycle. After you shorten the TTL, Tablestore deletes historical expired data in a subsequent deletion cycle.

The following example updates the TTL of example_index for example_table to seven days and queries the updated value.

index_meta = SearchIndexMeta(
    fields=None,
    time_to_live=7 * 24 * 60 * 60,
)
client.update_search_index(
    "example_table",
    "example_index",
    index_meta,
)

updated_meta, _ = client.describe_search_index(
    "example_table",
    "example_index",
)
print(updated_meta.time_to_live)

Parameters

The update_search_index method contains the following parameters.

Name

Type

Description

table_name (required)

str

The table name.

index_name (required)

str

The search index name.

index_meta (required)

SearchIndexMeta

The search index configurations to update.

Search index configurations

index_meta is a SearchIndexMeta object that contains the following parameters for a TTL update.

Name

Type

Description

fields (required)

List[FieldSchema]

Set this parameter to None. The update request does not modify index fields.

time_to_live (optional)

int

The TTL of index data in seconds. Default value: -1. Set the value to -1 or a positive int32 value. A value of -1 indicates that data does not expire. The maximum int32 value is equivalent to approximately 68 years.

Examples

Disable the TTL

Set time_to_live to -1 so that data in the search index does not expire.

index_meta = SearchIndexMeta(fields=None, time_to_live=-1)
client.update_search_index(
    "example_table",
    "example_index",
    index_meta,
)