Reputation: 311
I have a node which holds property is an Array. The node label is 'Person' and the name of property is 'Phone'. Which function in original neo4j should I use? Or which apoc function should I use?
Upvotes: 0
Views: 838
Reputation: 67044
If you do not want to return an array, but each array member as a separate record, you can use the UNWIND clause.
For example:
MATCH (p:Person {id: 123})
UNWIND p.Phone as phone_number
RETURN phone_number;
Upvotes: 1
Reputation: 326
To return just the value (array in this case) of an individual property is no different if it's an array of strings (for example) or just a regular string.
Let's say you have the following node:
(a:Person {Phone: ["Apple iPhone 8", "Samsung Galaxy S6"]})
We can see that this is a node with a property of phone that has a value of an array. The array in this case contains two strings, "Apple iPhone 8" and "Samsung Galaxy S6".
To return the values of the array, simply match the node in some way (if you've got more unique properties, you can uniquely match this node) and return the property name, perhaps like the following:
match (a:Person)
return a.Phone
Your returned values will then be the array that is assigned as the value of the Phone property:
["Apple iPhone 8", "Samsung Galaxy S6"]
You don't need a built-in function to achieve this.
Upvotes: 0