A suffix query (SuffixQuery) finds data in a search index that ends with a specific string. For example, you can look up a package delivery by using the last four digits of a phone number.
How it works
To run a SuffixQuery, specify the suffix value to match.
Only the FuzzyKeyword data type supports suffix queries. FuzzyKeyword is optimized for fuzzy search operations such as SuffixQuery, PrefixQuery, and wildcard query, and delivers stable performance regardless of data volume.
-
Fields of the
FuzzyKeywordtype do not support sorting or aggregation. If you need to sort or perform aggregation on aFuzzyKeywordfield, you can create avirtual columnof theKeywordtype for this purpose. -
To simulate a suffix query on a
Keywordfield, reverse the string when writing data and then use a prefix query (PrefixQuery) to search for the data.
API
Call the Search or ParallelScan operation with the query type set to SuffixQuery.
Parameters
|
Parameter |
Description |
|
query |
Set the query type to SuffixQuery. |
|
fieldName |
The field to match. |
|
suffix |
The suffix value. |
|
getTotalCount |
Specifies whether to return the total number of matched rows. The default value is false. Returning the total number of matched rows affects query performance. |
|
weight |
The query weight. This parameter is used for score-based sorting in full-text index scenarios. A higher weight value results in a higher score for the matched rows. The value must be a positive floating-point number. This parameter affects only the scores of the returned results, not the number of results. |
|
tableName |
The name of the data table. |
|
indexName |
The name of the search index. |
|
columnsToGet |
The columns to return. This includes the returnAll and columns settings. By default, returnAll is false. If returnAll is false, you can use columns to specify the columns to return. If you do not specify columns, only the primary key columns are returned. If you set returnAll to true, all columns are returned. |
Usage
Perform a suffix query by using the Tablestore console or an SDK. Before you begin, complete the following prerequisites:
-
You have created a
RAM userand granted it permissions to access Tablestore. For more information, see Use the AccessKey pair of a RAM user to access Tablestore. -
You have created a data table. For more information, see Operations on data tables.
-
You have created a search index for the data table. For more information, see Create a search index.
Billing
Querying data by using a Search Index consumes read throughput. For more information, see Search Index metering and billing.
FAQ
Related topics
Search Index supports various query types for multi-dimensional data queries, including term query, terms query, match all query, match query, phrase match query, range query, prefix query, suffix query, wildcard query, token-based wildcard query, boolean query, geo query, nested query, vector search, and exists query.
When you query data, you can sort and paginate the result set or perform collapsing (deduplication).
For data analysis, such as finding the maximum or minimum value, calculating a sum, or counting rows, you can use the statistical aggregation or SQL query features.
To quickly export data regardless of the result set order, you can use the Parallel Scan feature.