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 description | CDT context |
---|---|
Records with a specific value at index X of a List | list_index::2:: |
Records with a specific value at index X of a Map | map_index::2:: |
Records with a specific value at Rank X of a List nested inside a top level List at index Y | list_index::0::, list_rank::4:: |
Records with a specific value at Rank X of a Map nested inside a top level Map at MapKey Y | map_key:string:obj::, map_key:string:subobj::, map_rank::0:: |
Records with a specific value at Key X of a Map | map_key:string:oid:: |
Records with a specific string value at Key Y of a nested Map at Key X | map_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 description | Index Collection Type value | CDT Context |
---|---|---|
Records with specific string value in a nested List at a Map Index | List | map_index::0:: |
Records with a specific numeric value as Map Key in a top level Map | Map keys | (none) |
Records with a specific string value as Map Value in a nested Map at a Map Key | Map values | map_key:string:obj |
Records with a numeric value range in a nested List inside a top level list, at a specific Rank | List | list_index::-1:: |