Search indexes support three string-related data types: Keyword, FuzzyKeyword, and Text. Select the appropriate type based on your query requirements.
Background
In Tablestore data tables, the primary string type is String — equivalent to the string type in C++ and Java. Search indexes subdivide this single type into three specialized variants to support different query patterns:
|
Type |
Best for |
|
Keyword |
Exact match, range queries, sorting, and aggregation |
|
FuzzyKeyword |
High-performance wildcard, prefix, and suffix queries at any dataset size |
|
Text |
Full-text search with tokenization and relevance scoring |
Data type mappings
The String type in data tables maps directly to Keyword, FuzzyKeyword, or Text in search indexes. Using the virtual column feature, you can also map Integer or Double types to any of these three string types.
|
Data type in tables |
Method |
Data type in search indexes |
|
String |
Direct usage |
Keyword |
|
FuzzyKeyword |
||
|
Text |
||
|
Integer |
Virtual column |
Keyword |
|
FuzzyKeyword |
||
|
Text |
||
|
Double |
Virtual column |
Keyword |
|
FuzzyKeyword |
||
|
Text |
Data types
Keyword
Keyword treats a string as a single, indivisible value — the same way string fields work in relational databases. It supports term query, terms query, range query, wildcard query, prefix query, and exists query (null value query), as well as sorting and statistical aggregation (including GroupBy).
Good candidates for Keyword: user IDs, status codes, email addresses, country codes, and any field where you query exact values or run aggregations.
On datasets with more than one million entries, wildcard and prefix query performance degrades as the dataset grows. Use FuzzyKeyword if high-performance fuzzy matching at scale is required.
Text
Text is designed for full-text search. Before indexing, the system splits a string into tokens using the tokenization method you configure, then indexes each token individually. At query time, the query string goes through the same tokenization before matching against the index.
Because Text indexes tokens rather than the original value, it supports relevance scoring, result highlighting and summary, match query, and match phrase query. It does not support exact term queries, sorting, or aggregation.
Good candidates for Text: product descriptions, article content, user reviews, and any field where you search for words or phrases within a longer string.
For available tokenization methods, see Tokenization.
FuzzyKeyword
FuzzyKeyword is optimized for wildcard, prefix, and suffix queries. It pre-stores substrings of each field value in the index, so queries scan a compact index structure rather than scanning values row by row. Wildcard and prefix query performance stays consistently fast regardless of dataset size.
Good candidates for FuzzyKeyword: log messages, file paths, product SKUs, and any field where users type partial strings to search.
For suffix queries, use SuffixQuery with the FuzzyKeyword type. An alternative — reversing the data and running PrefixQuery on a Keyword field — is available but delivers lower performance.
FuzzyKeyword fields do not support sorting or statistical aggregation. To sort or aggregate a FuzzyKeyword field, use the virtual column feature to map it to a Keyword type.
If a field requires multiple query features such as term query, high-performance fuzzy query, and full-text search, use the virtual column feature to map one table column to three search index columns of the Keyword, Text, and FuzzyKeyword types respectively. For more information, see Virtual columns.
Type comparison
The three string types differ in supported query features and maximum field lengths.
A check mark (✓) indicates that the feature is supported. A cross mark (×) indicates that the feature is not supported.
|
Feature |
Keyword |
FuzzyKeyword |
Text |
|
✓ |
× |
× |
|
|
✓ |
× |
× |
|
|
✓ |
× |
× |
|
|
✓ |
✓ |
✓ |
|
|
✓ |
× |
× |
|
|
✓ |
× |
× |
|
|
× |
× |
✓ |
|
|
Full-text search: Relevance score |
× |
× |
✓ |
|
Full-text search: Highlighting and summary |
× |
× |
✓ |
|
× |
× |
✓ |
|
|
× |
× |
✓ |
|
|
✓ (Lower performance on large datasets) |
✓ (High performance) |
× |
|
|
✓ (Lower performance on large datasets) |
✓ (High performance) |
× |
|
|
Suffix query |
× |
✓ |
× |
|
Maximum length |
4 KB |
2 KB |
2 MB |