Database Reference
In-Depth Information
Returning relationships
Sometimes it makes more sense to query the graph for certain relationships. Suppose you
want to display the ratings a user has given to the movies they've has seen. The rating is
a property of a HAS_SEEN relationship (the actual property name is stars , referring to
the number of stars awarded to the movie), so you need to return those relationships. The
following snippet illustrates this:
The query starts by looking up user John Johnson from the index and matching all movie
nodes he has seen . Then it returns the instances of the HAS_SEEN relationship. Note
that to return a relationship, it needs to have an identifier (here r ).
The output of this query would look like this:
| :HAS_SEEN[2] {stars->5} |
If you're only interested in the stars property of the relationship, you can return just that
propertyfromthequery.Justlikenodeproperties,relationshippropertiescanbereferenced
in the return clause. Here's a snippet that illustrates this:
This time, instead of the entire relationship entity, you're only returning the stars prop-
erty you're interested in.
Returning paths
In addition to nodes and properties, you can return entire paths from the Cypher query.
Forexample,whenyou'relookingformovierecommendationsbasedonthemoviesJohn's
friends have seen, you may be interested in finding out how each movie is recommended
Search WWH ::




Custom Search