apoc.map.values

Details

Syntax

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

Description

Returns a LIST<ANY> indicated by the given keys (returns a null value if a given key is missing).

Arguments

Name

Type

Description

map

MAP

A map to extract values from.

keys

LIST<STRING>

A list of keys to extract from the given map. The default is: [].

addNullsForMissing

BOOLEAN

Whether or not to return missing values as null values. The default is: false.

Returns

LIST<ANY>

Usage Examples

The following examples return a list of values for the keys name and country, and a null value for the missing key missingKey, using both APOC and Cypher:

apoc.map.values
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN apoc.map.values(map, ["name", "country", "missingKey"], true) AS output
Using Cypher’s list comprehension
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN [k IN ["name", "country", "missingKey"] | map[k]] AS output
Results
output

["Cristiano Ronaldo","Portugal",null]

The following examples return a list of values for the keys name and country, but nothing for the missing key missingKey, using both APOC and Cypher:

apoc.map.values
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN apoc.map.values(map, ["name", "country", "missingKey"], false) AS output
Using Cypher’s list comprehension
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN [k IN ["name", "country", "missingKey"] WHERE k IN keys(map) | map[k]] AS output
Results
output

["Cristiano Ronaldo","Portugal"]