I would like Cypher REDUCE to work with a map as an accumulator. As input I have a list of tuples (key,value) which I want to convert into a map.
Something like this:
REDUCE(map={}, row IN coll | SET map[row.key]=row.value)
I'd prefer
REDUCE(map={}, row IN coll | map + { (row.key) : row.value})
Am 22.08.2016 um 10:36 schrieb Rickard Öberg [email protected]:
I would like Cypher REDUCE to work with a map as an accumulator. As input I have a list of tuples (key,value) which I want to convert into a map.
Something like this:
REDUCE(map={}, row IN coll | SET map[row.key]=row.value)—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
any updates on this issue?
apoc helps these days:
with [{a:1, x:'y'}, {b:2, y:'z'}] as coll
return reduce(acc={}, x in coll | apoc.map.merge(acc, x))
Reduce works with any accumulator, what is missing from Cypher is a way to to merge maps. For this I refer to this feature request: https://github.com/neo4j/neo4j/issues/4470
But, since APOC already provides such functions:
apoc.map.merge(base, patch)
apoc.map.updateTree(tree, key, value)
we currently don't consider adding these functions into Neo4j.
Most helpful comment
I'd prefer