Skip to main content
Loading

Secondary Index CDT Examples

Overview

This page explains Collection Data Type (CDT) context specifications for indexing fields within CDTs, and how to define a collection index.

The following examples explain Collection Data Type (CDT) context specifications for indexing fields within CDTs. For more information about the secondary index creation UI, see Secondary Indexes.

Equality and range queries

Query descriptionCDT context
Records with a specific value at index X of a Listlist_index::2::
Records with a specific value at index X of a Mapmap_index::2::
Records with a specific value at Rank X of a List nested inside a top level List at index Ylist_index::0::, list_rank::4::
Records with a specific value at Rank X of a Map nested inside a top level Map at MapKey Ymap_key:string:obj::, map_key:string:subobj::, map_rank::0::
Records with a specific value at Key X of a Mapmap_key:string:oid::
Records with a specific string value at Key Y of a nested Map at Key Xmap_key:string:obj::, map_key:string:attr_2::

Collection indexes

Collection indexes are defined on List and Map elements with the collection type LIST (list values in the List), MAPKEYS (key values in the Map), or MAPVALUES (values in the Map). These indexes can be used for equality queries on integer and string elements, as well as range queries on integer elements.

To define a collection index, in the secondary index creation panel in the Cloud console click Index Collection Type and select the appropriate value from the dropdown.

Query descriptionIndex Collection Type valueCDT Context
Records with specific string value in a nested List at a Map IndexListmap_index::0::
Records with a specific numeric value as Map Key in a top level MapMap keys(none)
Records with a specific string value as Map Value in a nested Map at a Map KeyMap valuesmap_key:string:obj
Records with a numeric value range in a nested List inside a top level list, at a specific RankListlist_index::-1::