All Products
Search
Document Center

Tablestore:CreateSearchIndex

Last Updated:Sep 03, 2024

Creates a search index.

Note

For more information about search indexes, see Overview.

Usage notes

Before you create a search index, make sure that the max versions of the data table is set to 1 and the time to live (TTL) of the data table meets one of the following conditions:

  • The TTL of the data table is set to -1, which specifies that data in the data table never expires.

  • The TTL of the data table is set to a value other than -1, and update operations on the data table are prohibited.

Request syntax

message CreateSearchIndexRequest {
    required string table_name = 1;
    required string index_name = 2;
    optional IndexSchema schema = 3;
    optional string source_index_name = 4;
    optional int32 time_to_live = 5; // unit is seconds
}

Parameter

Type

Required

Description

table_name

string

Yes

The name of the data table.

index_name

string

Yes

The name of the search index.

schema

IndexSchema

Yes

The schema of the search index.

source_index_name

string

No

The name of the source search index. This parameter is required only when you want to dynamically modify a schema.

time_to_live

int32

No

The TTL of the search index. TTL specifies the duration during which the data is retained. Default value: -1. Unit: seconds.

If the retention period exceeds the value of the time_to_live parameter, Tablestore automatically deletes expired data.

The minimum value of the time_to_live parameter is 86400, which is equal to one day. A value of -1 specifies that data never expires.

For more information about the TTL of search indexes, see Specify the TTL of a search index.

Response syntax

message CreateSearchIndexResponse {
}

Check whether an HTTP status code 200 is returned to determine whether the call is successful.

  • If an HTTP status code 200 is returned, the call is successful.

  • If an HTTP status code 400 or 500 is returned, the call failed.

    An error message is returned for a failed call. For more information, see Error.

Use Tablestore SDKs

You can use the following Tablestore SDKs to create a search index: