Skip to content
Developer Edition runs on one host and does not require a product license file. Need multi-host deployment or performance testing at scale? Explore Enterprise Edition

Map types

A map is a constructed data type used to store an unordered collection of key-value pairs. Each key in a map is unique and associated with a specific value.

Maps are enclosed in curly braces with key-value pairs separated by commas (,). Each key is separated from its corresponding value by a colon (:).

The map type must be declared using the MAP<key_type, value_type> syntax, where key_type and value_type specify the data types of the keys and values, respectively. Both key_type and value_type can be any predefined data type or constructed data type other than records and paths.

Declaration example

'''
CREATE GRAPH TYPE IF NOT EXISTS map_type AS {
    NODE person 
     ( {
        id INT PRIMARY KEY,
        name STRING,
        attributes MAP<STRING, BOOL> DEFAULT MAP{ 'is_student': false, 'is_employed': true}
     } )
}
'''

Supported operators

The map type supports the following operators:

Operator Name Description Example Result
|| Union Merges two maps into one. If both maps contain the same key, the value from the first map is retained. RETURN MAP{'a': 1, 'b': 2} || MAP{'b': 3, 'c': 4} {a:1,b:2,c:4}
IN Inclusion Checks if a specific key exists in the map. RETURN 'a' IN MAP{'a': 1, 'b': 2} true
NOT IN Exclusion Checks if a specific key does not exist in the map. RETURN 'c' NOT IN MAP{'a': 1, 'b': 2} true

More information

Map literals