All Products
Search
Document Center

Tablestore:Term query

Last Updated:May 29, 2025

A term query uses exact matches to retrieve data from a data table. A term query is similar to a query based on string matching.

Usage notes

  • For non-text fields such as Keyword or Integer fields, the field value must exactly match the term to meet the query conditions.

  • We recommend that you do not use term queries for Text fields because semantic tokenization is unpredictable and may change with algorithm iterations and language changes. Currently, a term query on a Text field searches whether individual tokens exactly match the term. If you want to use the entire field value to match the term without tokenization, you can use the virtual column feature to convert the Text type to Keyword type and then perform a term query on the Keyword field. For Text fields, as long as there are tokens that can be exactly matched, the query conditions are met. The term is not tokenized. For example, if the value of a Text field is "tablestore is cool", and the value is tokenized into three tokens: "tablestore", "is", and "cool", the query conditions are met when the term is "tablestore", "is", or "cool".

Procedure

  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 that you want to manage or click Manage Instance in the Actions column of the instance.

    4. On the Tables tab of the Instance Details tab, click the name of the data table or click Indexes in the Actions column of the data table.

  2. On the Indexes tab, find the search index that you want to use to query data and click Manage Data in the Actions column.

  3. In the Search dialog box, configure query parameters.

    1. By default, the system returns all attribute columns. To return specific attribute columns, turn off All Columns and specify the attribute columns that you want to return. Separate multiple attribute columns with commas (,).

      Note

      By default, the system returns all primary key columns of the data table.

    2. Select the And, Or, or Not logical operator based on your business requirements.

      If you select the And logical operator, data that meets the query conditions is returned. If you select the Or operator and specify a single query condition, data that meets the query condition is returned. If you select the Or logical operator and specify multiple query conditions, data that meets one of the query conditions is returned. If you select the Not logical operator, data that does not meet the query conditions is returned.

    3. Select an index field and click Add.

    4. Select TermQuery(TermQuery) from the Query Type drop-down list and specify the field value.

    5. By default, the sorting feature is disabled. If you want to sort the query results based on specific fields, turn on Sort and specify the fields based on which you want to sort the query results and the sorting order.

    6. By default, the aggregation feature is disabled. If you want to collect statistics on a specific field, turn on Collect Statistics, specify the field based on which you want to collect statistics, and then configure the information that is required to collect statistics.

  4. Click OK.

    Data that meets the query conditions is displayed in the specified order on the Indexes tab.

Development integration

You can perform a term query by using Tablestore SDKs or the Tablestore CLI:

Billing rules

When you use a search index to query data, you are charged for the read throughput that is consumed. For more information, see Billable items of search indexes.

FAQ

References