All Products
Search
Document Center

Tablestore:Update search index configurations

Last Updated:Aug 20, 2026

Tablestore SDK for Java updates the time-to-live (TTL) of a search index.

Prerequisites

Before you begin, ensure that you have:

Description

Call updateSearchIndex to update the TTL of a search index.

public UpdateSearchIndexResponse updateSearchIndex(UpdateSearchIndexRequest request)

To add or remove index fields or change field types, routing fields, or presorting settings, see Dynamically modify a search index schema.

Important

Consider the following rules when you configure a TTL:

  • Table and search index TTLs are independent. The index TTL cannot exceed the table TTL. To shorten both TTLs, update the search index before the table.

  • Tablestore removes expired index data in daily cleanup tasks. Queries may return expired data before the next cleanup task runs.

  • After you shorten the TTL, subsequent cleanup tasks remove existing data that has expired under the new setting.

The following example updates the TTL of example_index for example_table to seven days.

String tableName = "example_table";
String indexName = "example_index";
UpdateSearchIndexRequest request =
        new UpdateSearchIndexRequest(tableName, indexName);
request.setTimeToLiveInDays(7);

client.updateSearchIndex(request);

After the request succeeds, query the search index information and verify that timeToLive is 604800 seconds.

Parameters

UpdateSearchIndexRequest uses the following parameters to update an index TTL:

Name

Type

Description

tableName (required)

String

The table name.

indexName (required)

String

The search index name.

timeToLive (required)

Integer

The index data TTL in seconds. Valid values are -1 and positive int32 values. A value of -1 means that data does not expire. The maximum value is equivalent to approximately 68 years. Call setTimeToLive(int, TimeUnit) to specify a time unit, or call setTimeToLiveInDays(int) to specify the TTL in days.