A search index uses an inverted index and a column store to enable complex, multi-dimensional queries and statistical analysis on large datasets. You can create a search index for a data table to accelerate queries. When you create the index, you must add the fields that you want to query. You can also configure advanced options such as a routing key, Time to Live (TTL), and pre-sorting.
Usage notes
-
Include all fields you need to query in a single search index. Do not create a separate search index for each field.
-
After you create a search index, it may take a few seconds to initialize. During this time, writes to the data table are not affected, but you cannot query the index or its metadata.
-
For information about the limits on the number of rows, total size, and number of fields for a search index, see Search index limits.
Procedure
-
Go to the Indexes tab.
-
Log on to the Tablestore console.
-
In the top navigation bar, select a resource group and a region.
-
On the Overview page, click an instance name or click Manage Instance in the Actions column.
-
On the Instance Details tab, in the Tables section, click a data table name or click Indexes in the Actions column.
-
-
On the Indexes tab, click Create Search Index.
-
In the Create Index dialog box, configure the search index.
-
An index name is automatically generated. You can use the generated name or specify a custom one.
-
Select a schema generation type.
Important-
The Field Name and Field Type must match the corresponding fields in the data table. For mappings between data table field types and search index field types, see Data types.
-
To highlight content that meets specific conditions in a Text type field, enable highlighting for that field. For more information, see summary and highlighting.
-
If you set schema generation type to Manual, enter the field name, select the field type, and specify whether to enable Array for each field.
-
If you set schema generation type to Auto Generate, Tablestore automatically uses the primary key and attribute columns from the data table as index fields. You can then select the field type and specify whether to enable Array for each field.
NoteIn some cases, you can use a virtual column to optimize query performance.
-
-
To configure options such as Time to Live, routing key, or pre-sorting, enable Advanced Settings and configure the parameters as described in the following table.
Parameter
Description
routing key
Specifies the fields for data routing. You can select one or more primary key columns as routing fields, though one is usually sufficient. If you select multiple fields, their values are concatenated to form a single routing key.
The system indexes records with the same routing key value into the same data partition.
Time to Live
The retention period for data in the search index, in seconds. The default value is -1, which means the data never expires.
The value must be at least 86,400 seconds (one day) or -1. The Time to Live (TTL) of the search index must be less than or equal to the TTL of its data table.
To automatically delete expired data, set a TTL. Data is deleted when its age exceeds the TTL value.
pre-sorting
Defines the default sort order for query results. This setting determines the physical sort order of data within the search index.
Pre-sorting supports sorting by primary key or by a specific field value. If you do not specify a custom sort order, the index defaults to sorting by primary key. Choose the method that best fits your query patterns.
ImportantSearch indexes that contain Nested type fields do not support pre-sorting.
-
-
Click OK.
After the search index is created, you can view its details, including basic information, metrics, routing key, indexed fields, and pre-sorting settings, by clicking Index Details in the Actions column of the index list.
Development integration
You can create a search index using the Tablestore SDKs or the Tablestore CLI.
Related topics
-
Query types
-
Basic queries: Match all query, Term query, Terms query, Fuzzy query (Wildcard query, Prefix query, Suffix query, Tokenization-based wildcard query), Range query, Exists query, Geo query (for Geo-point fields), Nested query (for Nested fields), and Collapse (distinct)
-
Boolean queries: Boolean query
-
Full-text search (for Text type fields): Match query, Match phrase query, Tokenization, and summary and highlighting
-
Vector search (for Vector type fields): Vector search, Use vector search, and Generate vectors
-
-
Data analysis: Aggregation, SQL query, and Computing and analysis
-
Data export: Parallel scan