Database Reference
In-Depth Information
Loading multiple nodes by IDs
To use multiple IDs in the start clause, you need to list ID arguments as comma-separ-
ated values, as the following snippet demonstrates:
The start clause specifies two node IDs, using a single identifier: user . Next
comes the pattern matching to find all movies that the user has seen. The user identifier
referenceseithernodes 1 or 3 ,sothepatternwillmatchallmoviesthateitherUser1(John,
in this case) or User 3 (Jack) has seen. The resulting output looks like this:
|Node[5]{name->"Alien",type->"Movie"}|
|Node[4]{name->"Fargo",type->"Movie"}|
Note
The distinct keyword in the return clause of the last query was used to eliminate
duplicate results. Distinct works the same as in SQL queries—by excluding duplicated
columns in the result set. Both Jack and John have seen Fargo , so if you didn't use the
distinct keyword, Fargo would be returned twice in the result.
Sofar,sogood.Butmostofthetimeyoudon'tknowtheIDsofthenodesyou'reinterested
in—you know some other property, like a user's name, a movie title, or something similar.
In the next section you'll learn how to use that information to load starting nodes.
Using an index to look up the starting node(s)
In chapter 5 we introduced indexing as a recommended way to look up starting nodes in
a traversal. Cypher also supports direct access to Lucene indexes, so the typical traversal
idiom in Neo4j becomes
1 . Look up one or more nodes using the Lucene index.
Search WWH ::




Custom Search