Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get values of map in cypher

Tags:

maps

neo4j

cypher

Starting from a map map in cypher, I can get the keys via keys(map), but it seems there is no values analogon, also APOC doesn't seem to have a suitable procedure.

edit: using newest neo4j and apoc versions

Did I miss anything?

like image 368
tscherg Avatar asked Sep 06 '25 08:09

tscherg


2 Answers

The List Comprehension syntax can produce a list of map values fairly succinctly:

[k IN KEYS(map) | map[k]]
like image 121
cybersam Avatar answered Sep 09 '25 09:09

cybersam


As a workaround, you can use this solution using reduce() and keys() functions:

match(node)
with reduce(values = [], key in keys(node) | values + node[key]) as values
return values
like image 21
Bruno Peres Avatar answered Sep 09 '25 09:09

Bruno Peres