All Products
Search
Document Center

Tablestore:Quick start for search indexes

Last Updated:May 22, 2025

If you want to use query types, such as query based on non-primary key columns or Boolean query to query data in a data table, you can create a search index for the data table and then use the search index to query data in the data table. This topic describes how to quickly use a search index in the Tablestore console.

Note

You can also quickly use a search index by using Tablestore SDKs or the Tablestore CLI.

Prerequisites

A data table for which the max Versions parameter is set to 1 is created. For more information, see Create a data table. The time to live (TTL) of the data table must meet 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.

  • If the TTL of the data table is not set to -1, update operations on the data table are prohibited (Allow Updates is set to No for the data table).

Procedure

Step 1: Create a search index

You can create a search index to accelerate data queries. You must add the fields that you want to query to the search index. You can configure advanced settings, such as the Routing Key, Time to Live, and Pre-sorting parameters, based on your business requirements.

  1. Go to the Indexes tab.

    1. Log on to the Tablestore console.

    2. In the top navigation bar, select a resource group and a region.

    3. On the Overview page, click the name of the instance or click Manage Instance in the Actions column of the instance.

    4. In the Tables section of the Instance Details tab, click the name of the data table and click the Indexes tab. Alternatively, you can click Indexes in the Actions column of the data table.

  2. On the Indexes tab, click Create Search Index.

  3. In the Create Index dialog box, specify the index name based on your business requirements.

  4. Select Auto Generate for Schema Generation Type, and select the field type and specify whether to enable array based on your business requirements.

    In this example, the search index name is example_index. The search index contains four fields: id (Fuzzy Keyword), cost (Floating Point), name (String), and age (Long Integer).

    Important

    The value of Field Name for each field in the search index must be the same as the field name in the data table, and the data type of each field in the search index must match the data type of the field in the data table.

    image

  5. Click OK.

    After the search index is created, in the Actions column of the search index in index list, click Index Details to view the basic information, index metrics, routing key, index fields, and pre-sorting information of the search index.

Step 2: Use the search index to query and analyze data

When you use a search index to query data, you can select the query types based on your business requirements. When you query data, you can specify the columns that you want to return, the sorting method for returned data, and whether to perform statistical analysis on the data.

This example demonstrates how to use range query to query rows where the cost column value is greater than or equal to 10 and less than or equal to 1000, and calculate the sum of the cost column values in the rows that meet the conditions.

  1. On the Indexes tab, click Manage Data in the Actions column of the search index.

  2. In the Search dialog box, select cost as the index field, and click Add.

    image

  3. Configure the range query conditions.

    1. Set Query Type to RangeQuery(RangeQuery).

    2. Set the maximum value to 1000 and the minimum value to 10.

  4. Turn on the Collect Statistics switch and configure the statistical conditions.

    1. Select cost as the statistical field and click Add.

    2. Set Statistics Type to Sum and set Item to costtotal.

  5. Click OK.

    The data that meets the query conditions is displayed on the Indexes tab.

FAQ

References

The query types supported by search indexes in the Tablestore console include term query, terms query, range query, prefix query, suffix query (only for Fuzzy Keyword fields), wildcard query, match query, match phrase query, exists query, Boolean query, geo query (geo distance query, geo bounding box query, and geo polygon query, only for Geo fields), nested query (only for Nested fields), and KNN vector query.