10.2. Map Functions

apoc.map.fromNodes(label, property)

creates map from nodes with this label grouped by property

apoc.map.fromPairs([[key,value],[key2,value2],…​])

creates map from list with key-value pairs

apoc.map.fromLists([keys],[values])

creates map from a keys and a values list

apoc.map.fromValues([key,value,key1,value1])

creates map from alternating keys and values in a list

apoc.map.merge({first},{second}) yield value

creates map from merging the two source maps

apoc.map.mergeList([{maps}]) yield value

merges all maps in the list into one

apoc.map.setKey(map,key,value)

returns the map with the value for this key added or replaced

apoc.map.removeKey(map,key)

returns the map with the key removed

apoc.map.removeKeys(map,[keys])

returns the map with the keys removed

apoc.map.clean(map,[keys],[values]) yield value

removes the keys and values (e.g. null-placeholders) contained in those lists, good for data cleaning from CSV/JSON

apoc.map.groupBy([maps/nodes/relationships],'key') yield value

creates a map of the list keyed by the given property, with single values

apoc.map.groupByMulti([maps/nodes/relationships],'key') yield value

creates a map of the list keyed by the given property, with list values

apoc.map.sortedProperties(map, ignoreCase:true)

returns a list of key/value list pairs, with pairs sorted by keys alphabetically, with optional case sensitivity

apoc.map.updateTree(tree,key,)

returns map - adds the {data} map on each level of the nested tree, where the key-value pairs match

apoc.map.values(map, [key1,key2,key3,…​],[addNullsForMissing]) returns list of values indicated by the keys

apoc.map.submap(map,keys,,[fail=true])

returns submap for keys or throws exception if one of the key doesn’t exist and no default value given at that position

apoc.map.mget(map,keys,,[fail=true])

returns list of values for keys or throws exception if one of the key doesn’t exist and no default value given at that position

apoc.map.get(map,key,[default],[fail=true])