Database Reference
In-Depth Information
The first two steps in the example are very familiar: find the starting node using the index
lookup , and find all its neighboring nodes using the match clause . The identifier
rel is used to reference every relationship later in the query. Finally, you return the type
ofeachrelationshipusingthe TYPE function,alongwiththecount
.As TYPE isanon-
aggregating function, the results will be grouped by relationship type.
Cypheralsosupportsfunctionsthatallowyoutoeasilyworkwithiterablecollectionswith-
in the query. As an example, let's solve the following problem: John would like to be in-
troduced to Kate on Facebook. He doesn't know Kate and would like to find out which of
his friends, and friends of his friends, know her, up to the third level. Because he needs to
use Facebook, he's only interested in people who are on Facebook already (who have the
facebookId property set). The following snippet shows the required query:
You start the query by locating known starting nodes representing John and Kate in the
Neo4j database
. In the match clause you find all paths that connect John and Kate
byfollowingthe IS_FRIEND_OF relationshipsuptothethirdlevel
.You'reusingthe
identifier p to reference the matching path later in the query.
Search WWH ::




Custom Search