Search indexes use inverted indexes and column-oriented storage to address complex query needs when a large amount of data exists. After you create a search index in the Tablestore console, you can use the search index to query data.

Note For more information about search indexes, see Overview.

Create search indexes

  1. Log on to the Tablestore console.
  2. On the Overview page, click the name of the required instance or click Manage Instance in the Actions column that corresponds to the instance.
  3. In the Tables section of the Instance Details tab, click the name of the data table for which you want to create a search index and then click the Indexes tab. You can also click Indexes in the Actions column that corresponds to the data table.
  4. On the Indexes tab, click Create Search Index.
  5. In the Create Index dialog box, create a search index.
    fig_tablestore_009
    1. The system generates a search index name. You can also set Index Name to a specific value.
    2. Set Schema Generation Type.
      Notice The Field Name and Field Type values must be the same as those of the data table. For more information about the mapping of field types between the data table and search index, see Data types of column values.
      • If you set Schema Generation Type to Manual, set field names and supported data types for the field values. Specify whether to turn on Array.
      • If you set Schema Generation Type to Auto Generate, the system automatically uses the primary key columns and attribute columns of the data table as index fields. Set supported data types for the field values. Specify whether to turn on Array.
      Note To optimize performance in some cases, you can use virtual columns. For more information about virtual columns, see Virtual columns.
  6. Click OK.

    After the search index is created, click Index Details in the Actions column that corresponds to the search index. You can view the information about the search index, such as the metering information and index fields.

Query data

You can use an existing search index to query data.

  1. Log on to the Tablestore console.
  2. On the Overview page, click the name of the required instance or click Manage Instance in the Actions column that corresponds to the instance.
  3. In the Tables section of the Instance Details tab, click the name of the data table whose search index you want to view and then click the Indexes tab. You can also click Indexes in the Actions column that corresponds to the data table.
  4. Click Query in the Actions column that corresponds to the search index.
    fig_tablestore_010
  5. On the Query Data tab, click Search. In the Search dialog box, set filter conditions.
    1. By default, the system returns all columns. To return specified attribute columns, turn off All Columns. Enter the attribute columns to return. Separate multiple attribute columns with commas (,).
      Note By default, the primary key columns of the data table are returned.
    2. Select index fields. Click Add. Set query methods and values for the index fields.
    3. By default, the sorting feature is disabled. To enable sorting, turn on Sort to sort query results based on the index fields. Add index fields and select a sorting method.
  6. Click OK.
    Data that meets the filter conditions is displayed in the specified order on the Indexes tab.

Use Tablestore SDKs

For more information about how to use Tablestore SDKs to implement search index, see the following topics: