Tablestore SDK for Java updates the time-to-live (TTL) of a search index.
Prerequisites
Before you begin, ensure that you have:
-
Tablestore SDK for Java 5.12.0 or later and an initialized client
-
An existing table and search index, with
UpdateRowupdates disabled for the table. For table update settings, see Update table configurations
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.
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) |
|
The table name. |
|
indexName (required) |
|
The search index name. |
|
timeToLive (required) |
|
The index data TTL in seconds. Valid values are |