Search indexes provide special field types in addition to the basic field types such as Long, Double, Boolean, Keyword, Text, and Geopoint.

One special field type is the Array type, which can be attached to the basic field types. For example, combining the Long and Array types forms a long array. This field can contain multiple long integers. If the query matches any data in the field, the row is returned.

The other is the Nested type, which provides more features than the Array type.

Array type

Basic Array types are as follows:

  • Long Array

    An array of long integers. Example: “[1000, 4, 5555]“.

  • Boolean Array

    An array of Boolean values. Example: “[true, false]“.

  • Double Array

    An array of double-precision floating-point numbers. Example: “[3.1415926, 0.99]“.

  • Keyword Array

    A JSON array of strings.

  • Text Array

    A JSON array of text. Text JSON arrays are not frequently used.

  • GeoPoint Array

    An array of geographical locations. Example: “[\"34.2\", \"43.0\", \"21.4\", \"45.2\"]“.

The Array type is only supported in search indexes. Therefore, when the type of an index field involves Array, the field in the table must be of the String type. The basic data type, such as Long or Double, in the search index remains. For example, when a price field is of the Double Array type, the field type in the table must be of the String type, and the field type must be of the Double type and isArray must be set to true in the search index.

Nested type

A Nested column contains nested documents. A document or a row can contain multiple child documents that are saved to the same Nested column. You must specify the schema of child documents in the Nested column. The schema must include the fields of the child documents and the property of each field. The following example defines the format of a Nested column in Java:

// Specify the FieldSchema class for the child documents.
List<FieldSchema> subFieldSchemas = new ArrayList<FieldSchema>();
subFieldSchemas.add(new FieldSchema("tagName", FieldType.KEYWORD)
subFieldSchemas.add(new FieldSchema("score", FieldType.DOUBLE)
// Set FieldSchema of the child documents as subfieldSchemas of the Nested column.
FieldSchema nestedFieldSchema = new FieldSchema("tags", FieldType.NESTED)

This example defines the format of a Nested column named tags. The child documents include two fields: the KEYWORD field named tagName and the DOUBLE field named score.

Tablestore writes Nested columns as strings in JSON arrays to the table. The following example shows the data format of a Nested column:

[{"tagName":"tag1", "score":0.8}, {"tagName":"tag2", "score":0.2}]

This column contains two child documents. Even if a column contains only one child document, you must provide the strings in JSON arrays.

The Nested type has the following limits:
  1. Nested indexes do not support the IndexSort feature. However, IndexSort can improve query performance in many scenarios.
  2. The nested query provides lower performance than other types of queries.

Apart from the preceding limits, the Nested type supports all queries, sorting, and aggregation.