Before you use a search index, you must understand the data types supported by search indexes. You must also understand the mappings between the data types supported by search indexes and the data types supported by the data tables for which the search indexes are created.
Supported data types
Search indexes support the Long, Double, Boolean, Keyword, Text, Date, Geopoint, and Vector basic data types, the Array and Nested special data types, and virtual columns.
Tablestore SDK for Java V5.13.9 or later supports the Date data type in search indexes. To use the Date data type in search indexes, make sure that Tablestore SDK for Java V5.13.9 or later is obtained. For more information about the versions of Tablestore SDK for Java, see Version history of Tablestore SDK for Java.
Basic data types
Search indexes support the following basic data types: Long, Double, Boolean, Keyword, Text, Date, Geopoint, and Vector. The following table describes the basic data types.
Basic data type | Description |
Long | A 64-bit long integer. |
Double | A 64-bit double-precision floating-point number. |
Boolean | A Boolean value. |
Keyword | A string that cannot be tokenized. |
Text | A string or text that can be tokenized. For more information, see Tokenization. |
Date | The Date data type. You can specify the format of data of the Date type. For more information, see Date data type. |
Geopoint | A coordinate pair of a geographical location in the |
Vector | The Vector type. The value of a field of the Vector type is a string in the Float32 array format. The length of the array is the same as the number of dimensions of the field. For example, the number of dimensions of the vector string |
Array and Nested types
In addition to basic data types, such as Long, Double, Boolean, Keyword, Text, Date, Geopoint, and Vector, search indexes support two special data types: Array and Nested. The Array data type is suitable for storing a collection of the same type of data. The Nested data type is similar to the JSON data type and is suitable for storing data that has a hierarchical structure. For more information, see Array and Nested data types.
Array type
Nested type
Virtual columns
You can use the virtual column feature of search indexes to query new fields and the data of new field types without the need to modify the storage schema and data in the Tablestore tables. For more information, see Virtual columns.
The virtual column feature allows you to map a column in a table to a virtual column in a search index when you create the search index. The type of the virtual column can be different from that of the column in the table. This allows you to create a column without modifying the table schema and data. The new column can be used to accelerate queries or can be configured with different tokenization methods.
You can configure different tokenization methods for Text fields that are mapped to the same field in a table.
A single String column can be mapped to multiple Text columns of a search index. Different Text columns use different tokenization methods to meet various business requirements.
Query acceleration
You do not need to cleanse data or re-create a table schema. You need to only map required columns of a table to the columns in a search index. The column types can be different between the table and the search index. For example, you can map the numeric type to the Keyword type to improve the performance of a term query, and map the String type to the numeric type to improve the performance of a range query.
Data type mappings
The value of a field in a search index is the value of the field that has the same name in the data table for which the search index is created. The data types of the two values must match. The following table describes the matching rules.
Field data type in search indexes | Field data type in data tables |
Long | Integer |
Long Array | String |
Double | Double |
Double Array | String |
Boolean | Boolean |
Boolean Array | String |
Keyword | String |
Keyword Array | String |
Text | String |
Date | Integer and String |
Date Array | String |
Geopoint | String |
Geopoint Array | String |
Vector | String |
Nested | String |