Database Reference
In-Depth Information
Starting from the known node named john (with ID 1 ), you match the outgoing
IS_FRIEND_OF relationship to another node (which is left anonymous), which in turn
has a HAS_SEEN relationship to another named node, movie .
You don't need to name any relationships or intermediate nodes because you're not inter-
estedinthem;allyouwanttoreturnarenodesrepresentingmoviesthatJohn'sfriendshave
seen.
RunningthisquerywillreturnallmovienodesthatanyofJohn'sfriendshaveseen,wheth-
er or not John has seen them:
| Node[5]{name->"Alien",type->"Movie"} |
| Node[4]{name->"Fargo",type->"Movie"} |
| Node[6]{name->"Heat",type->"Movie"} |
If you want this social network to recommend movies based on the taste of John's friends,
then you should skip the movies that John has already seen. To get the result you want,
filtertheresultyougotinthepreviousexampleusingapatternthatmatchesmoviesalready
seen by John. Using Cypher, you can match multiple patterns in the same query, referen-
cing the same nodes in both patterns if required.
Look at the query in the following snippet:
Multiple patterns in Cypher are differentiated using a comma ( , ) as a separator. The first
pattern here is the one used in the previous example—matching movies that John's friends
have seen
. The second pattern matches all movies that John has seen already
.
Search WWH ::




Custom Search