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.

How to add multiple values to one property

I have data in CSV , like
Name id
AB 1
2
3
I have three id for one name and i have created node of person with name property(p:Person{name}) now i want to add id property and want all those id in that property like p:Person{name:AB,id:[1,2,3]} and i have to import data from CSV. How can i do that?

2 REPLIES 2

load csv with headers from <url> as row
merge (p:Person{name:row.name})
on create set p.id = [row.id]
on match set p.id = p.id + row.id

Be aware that schema indexes will not support looking up nodes by a value in a list property. If you need fast lookup by id, then this is best modeled a different way, with separate nodes containing the id that have relationships to the node that has the name.

For example, a :Person node with aliases, where we want to quickly lookup a person by a given alias. Rather than using a :Person node with a list property of aliases, we would model a :Person with multiple :Alias nodes that point to it, where the given alias property of the :Alias node is indexed, so we can quickly lookup by alias and traverse to the :Person using that alias.