As in the question. The word "first" is important - there may be more relationships that match the same condition.
Real use case: each relation has a timestamp property, and I want to find the first thing that happened before a certain time (for example, "before noon"). For instance:.
(head) -[time: 9]-> () -[time: 8]-> () -[time: 7]-> ...
-
Here is what I had (suppose we know what headnode is):
MATCH (head) -[prevs:next*0..]-> (x) -[rel:next]-> (y)
WHERE NONE(prev IN prevs WHERE prev.time < {time})
AND rel.time < {time}
RETURN x, rel, y
This suggests that "cross one or more relationships until we find one in front {time}, And none of the previous relationships have been before {time}."
, , , . , - NONE() .
, Cypher, ? , ? (IOW, - " " ?)
-
:
http://console.neo4j.org/r/b4v2tl
: 1001- node, / . "Toggle Viz", .
, . :
MATCH (head:Node {id: 0}) -[prevs:next*0..]-> (x) -[rel:next]-> (y)
WHERE NONE(prev IN prevs WHERE prev.time > 5)
AND rel.time > 5
RETURN x, rel, y
, .
, Neo4j . 0.. , . 0..10, . 10, , . 100.