Data Types and Secondary Index Fields

Secondary indexes support a specific set of data types. This section describes how indexed and included fields in secondary indexes behave for different categories of data types.

Data Types of Indexed Fields

Indexed fields in a secondary index must contain scalar data. Otherwise, if the field contains an array or nested document, MapR-DB excludes the corresponding document from the index. The indexed field can be a subfield of a nested document, provided the subfield is a scalar type. The indexed field cannot be an array element, even if the array element is scalar. See the table in the Scalar Data section of JSON Document Data Types for a list of scalar types.

The following table summarizes what MapR-DB supports, depending on the characteristics of the indexed field:

Characteristics of Indexed Field Behavior
Field contains scalar data Supported
Field path is a nested document subfield that contains scalar data Supported
Field contains nested document data Missing in index
Field contains array data Missing in index
Field is an individual array element Not supported

Data Types of Included Fields

There are no type restrictions on the included fields in an index.

Comparisons and Sorts on Indexed Fields

Comparisons and sorts across data types differ depending on whether the types are comparable or noncomparable. This is not specific to secondary indexes. But it impacts comparisons when using secondary indexes and the order MapR-DB stores data in an index. See Using Comparable JSON Document Data Types in Comparisons and Sorts and Using Noncomparable JSON Document Data Types in Comparisons and Sorts to learn which types fall into each category and to understand their behavior.