Database Reference
In-Depth Information
Neo4j. We'll assume that the ID of the John Johnson user node is known and stored in the
static variable
JOHN_JOHNSON_NODE_ID
:
Note
Ideally, you'd look up the starting node based on some property value instead of the node
ID. For example, you'd find the
user
node by its name or email address. Ad hoc node
this chapter, node lookups will be performed using the node ID.
Now that you have the starting node, you can traverse the graph to find the
movie
nodes
you're interested in.
4.1.2. Traversing direct relationships
To find all the movies John has seen, you first load John's node, then follow all the
HAS_SEEN
relationships from that node, as shown in the following listing.
Listing 4.1. Filtering movies by iterating through all relationships from the node