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
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 the name of the instance that you want to manage or click Manage Instance in the Actions column of the instance.
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.
On the Indexes tab, find the search index that you want to use to query data and click Manage Data in the Actions column.
In the Search dialog box, configure query parameters.
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 (,).
NoteBy default, the system returns all primary key columns of the data table.
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.
Select an index field and click Add.
Select TermQuery(TermQuery) from the Query Type drop-down list and specify the field value.
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.
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.
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
When you use a search index to query data, you can use the following query methods: term query, terms query, match all query, match query, match phrase query, prefix query, Suffix query, range query, wildcard query, fuzzy query, Boolean query, geo query, nested query, KNN vector query, and exists query. You can select query methods based on your business requirements to query data from multiple dimensions.
You can sort or paginate rows that meet the query conditions by using the sorting and paging features. For more information, see Perform sorting and paging.
If you want to analyze data in a data table, you can use the aggregation feature of the Search operation or execute SQL statements. For example, you can obtain the minimum and maximum values, sum, and total number of rows. For more information, see Aggregation and SQL query.
If you want to obtain all rows that meet the query conditions without the need to sort the rows, you can call the ParallelScan and ComputeSplits operations to use the parallel scan feature. For more information, see Parallel scan.