Reputation: 141
I have a question about extracting specific elements from array-valued properties in Neo4j. For example if the nodes in out database each have a property 'Scores', with Scores being an integer array of length 4. Is there a way to extract the first and fourth elements of every node in a path i.e. can we do something along the lines of -
start src=node(1), end =node(7)
match path=src-[*..2]-end
return extract(n in nodes(path)| n.Scores[1], n.Scores[4]);
p.s. I am using Neo4j 2.0.0-RC1
Upvotes: 0
Views: 2174
Reputation: 9853
Does this work for you?
START src=node(1), end=node(7)
MATCH path=src-[*..2]-end
RETURN extract(n in nodes(path)| [n.Scores[0], n.Scores[3]] )
Basically that's creating a collection for each node of the 1st and 4th (indexes start at 0) score. See 8.2.1. Expressions in general
An expression in Cypher can be:
...
A collection of expressions:
["a", "b"], [1,2,3],["a", 2, n.property, {param}], [ ].
Upvotes: 5