Databases Reference
In-Depth Information
CREATE (reply_1 { id : '7' , content: 'response' }),
(reply_1)-[:REPLY_TO]->(email_6),
(davina)-[:SENT]->(reply_1),
(reply_1)-[:TO]->(bob),
(reply_1)-[:TO]->(charlie);
CREATE (reply_2 { id : '8' , content: 'response' }),
(reply_2)-[:REPLY_TO]->(email_6),
(bob)-[:SENT]->(reply_2),
(reply_2)-[:TO]->(davina),
(reply_2)-[:TO]->(charlie),
(reply_2)-[:CC]->(alice);
CREATE (reply_3 { id : '9' , content: 'response' }),
(reply_3)-[:REPLY_TO]->(reply_1),
(charlie)-[:SENT]->(reply_3),
(reply_3)-[:TO]->(bob),
(reply_3)-[:TO]->(davina);
CREATE (reply_4 { id : '10' , content: 'response' }),
(reply_4)-[:REPLY_TO]->(reply_3),
(bob)-[:SENT]->(reply_4),
(reply_4)-[:TO]->(charlie),
(reply_4)-[:TO]->(davina);
This creates the graph in Figure 3-12 , which shows numerous replies and replies-to-
replies.
Now it is easy to see who replied to Bob's original email. First locate the email of interest,
then match against all incoming REPLY_TO relationships (there may be multiple replies),
and from there match against incoming SENT relationships: this reveals the sender(s).
In Cypher this is simple to express. In fact, Cypher makes it easy to look for replies-to-
replies-to-replies, and so on to an arbitrary depth (though we limit it to depth four here):
START email = node :email( id = '6' )
MATCH p=(email)<-[:REPLY_TO*1..4]-()<-[:SENT]-(replier)
RETURN replier.username AS replier, length (p) - 1 AS depth
ORDER BY depth
Search WWH ::




Custom Search