Update the configurations of a search index

更新时间: 2026-04-29 21:58:35

Updates the time to live (TTL) of a search index using Tablestore SDK for Node.js by calling the UpdateSearchIndex operation.

Prerequisites

Usage notes

  • The TTL of a search index is independent of and must be no greater than that of the data table for which the search index is created. If you want to decrease the TTL of a search index and the data table for which the search index is created, you must change the TTL of the search index before you change the TTL of the data table.

  • Tablestore automatically deletes expired data from search indexes every day. You can still query expired data in search indexes before the expired data is deleted. Tablestore automatically deletes the expired data in the next cycle.

  • After you change the TTL of data tables and search indexes, Tablestore automatically deletes the historical expired data from the data tables and search indexes in the next cycle.

Parameters

Parameter

Description

tableName (required)

The name of the data table.

indexName (required)

The name of the search index.

timeToLive (required)

The TTL of the search index, in seconds. Set to -1 for data that never expires. Set to a positive int32 value for a fixed expiration period. The maximum int32 value is approximately 68 years.

Examples

The following example sets the TTL of a search index to seven days (604,800 seconds):

let params = {
    tableName: '<TABLE_NAME>',
    indexName: '<SEARCH_INDEX_NAME>',
    timeToLive: 604800,  // 7 days in seconds (7 x 24 x 60 x 60)
}
client.updateSearchIndex(params, function (err, data) {
    if (err) {
        console.log('updateSearchIndex error:', err.toString());
    } else {
        console.log('updateSearchIndex success:', data);
    }
});

To calculate the timeToLive value for a different duration, multiply the number of days by 86400 (seconds per day). For example, 30 days is 2592000.

FAQ

[What do I do if the [table ttl] must be bigger than or equal search index ttl error message is returned when I modify the TTL of a data table?](t2633375.xdita#)

References

上一篇: List search indexes 下一篇: Query the description of a search index
阿里云首页 表格存储 相关技术圈