cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Improving Cypher code without using data type List

mkretsch
Node Clone

I have a quite simple network model focused on individuals and companies and their connected identifiers. To ease viewing for analysts, I take the relationship
(:Person) - [PHONE] -> (:Phone)
And create a phoneNumber property on the Person node using the name property of the Phone node. I created a list such that it supports more than one PHONE relationship and stakes the numbers as a list. However, I use Linkurious as our visualization software and it does not technically support lists as a data type. The solution still works, but any suggestions on how to complete the same task, but not as a list? Below is example of what I run in Neo4j to make these automated phoneNumber properties on Person nodes.

MATCH (n)-[:PHONE]->(p:Phone) WITH n, COLLECT (p.name) as phone_list SET n.phoneNumber = phone_list

Thanks in advance!

1 REPLY 1

Have you tried reduce (https://neo4j.com/docs/cypher-manual/current/functions/list/#functions-reduce😞 reduce(init = "", n IN phone_list| init + ","+ n.name+",") as phoneList (you've have to remove the trailling ',')