A path template n().e()...n() can apply filters on each node and edge of a path independently. Paths with circle can be filtered out, and the number of result of subquery can be limited.
NOTEFor the usage of basic templates
n(),e()and so on, please refer to Basic Templates.
Syntax:
null for any subquery that finds no result)| Parameter | Type | Specification | Description | Structure of Custom Alias |
|---|---|---|---|---|
no_circle() | / | / | To dismiss the paths with circles; see Basic Concept - Terminologies for the definition of circle | Not supported |
limit() | Int | -1 or >=0 | Number of results to return for each subquery, -1 means to return all results | Not supported |
Sample graph: (to be used for the following examples)

Example: Find single-node paths of @movie, carry all properties
UQLn({@movie}) as p return p{*}
ResultLéon Avatar The Terminator
Example: Find 4-step paths of @movie-@country-@movie-@director-@movie, carry all properties
UQLn({@movie}).re({@filmedIn}).n({@country}) .le({@filmedIn}).n({@movie}) .le({@direct}).n({@director}) .re({@direct}).n({@movie}) as p return p{*}
ResultLéon ----> France <---- The Terminator <---- James Cameron ----> Avatar Léon ----> USA <---- The Terminator <---- James Cameron ----> Avatar Léon ----> USA <---- Avatar <---- James Cameron ----> The Terminator The Terminator ----> USA <---- Avatar <---- James Cameron ----> The Terminator Avatar ----> USA <---- The Terminator <---- James Cameron ----> Avatar
Example: Find 1~4-step paths from Léon to Avatar, carry all properties
UQLn({@movie.name == "Léon"}).e()[:4].n({@movie.name == "Avatar"}) as p return p{*}
ResultLéon ----> France <---- The Terminator ----> USA <---- Avatar Léon ----> France <---- The Terminator <---- James Cameron ----> Avatar Léon ----> USA <---- The Terminator <---- James Cameron ----> Avatar Léon ----> USA <---- Avatar
Example: Find 1~4-step paths from Léon to Avatar and not passing France, carry all properties
UQLn({@movie.name == "Léon"}).e().nf({name != "France"})[:4].n({@movie.name == "Avatar"}) as p return p{*}
ResultLéon ----> USA <---- The Terminator <---- James Cameron ----> Avatar Léon ----> USA <---- Avatar
Example: Find shortest paths from Léon to Avatar within 4 steps, carry all properties
UQLn({@movie.name == "Léon"}).e()[*:4].n({@movie.name == "Avatar"}) as p return p{*}
ResultLéon ----> USA <---- Avatar
Analysis: The multi-edge template e()[*:N] or e().nf()[*:N] that represent shortest path must be the last edge template in the path.
Example: Find 4-step paths of @movie-@country-@movie-@director-@movie, with the initial-node and terminal-node representing the same node, carry all properties
UQLn({@movie} as a).re({@filmedIn}).n({@country}) .le({@filmedIn}).n({@movie}) .le({@direct}).n({@director}) .re({@direct}).n(a) as p return p{*}
ResultThe Terminator ----> USA <---- Avatar <---- James Cameron ----> The Terminator Avatar ----> USA <---- The Terminator <---- James Cameron ----> Avatar
Example: Find 4-step paths of @movie-@country-@movie-@director-@movie, remove paths with circles, carry all properties
UQLn({@movie}).re({@filmedIn}).n({@country}) .le({@filmedIn}).n({@movie}) .le({@direct}).n({@director}) .re({@direct}).n({@movie}).no_circle() as p return p{*}
ResultLéon ----> France <---- The Terminator <---- James Cameron ----> Avatar Léon ----> USA <---- The Terminator <---- James Cameron ----> Avatar Léon ----> USA <---- Avatar <---- James Cameron ----> The Terminator
Example: Find two 4-step paths of @movie-@country-@movie-@director-@movie, carry all properties
UQLn({@movie}).re({@filmedIn}).n({@country}) .le({@filmedIn}).n({@movie}) .le({@direct}).n({@director}) .re({@direct}).n({@movie}).limit(2) as p return p{*}
ResultLéon ----> France <---- The Terminator <---- James Cameron ----> Avatar Léon ----> USA <---- The Terminator <---- James Cameron ----> Avatar
Example: Find 2-step paths from Luc Besson to Avatar, carry all properties; return null if no result
UQLoptional n({@director.name == "Luc Besson"}).e()[2].n({@movie.name == "Avatar"}) as p return p{*}
Resultnull --null-- null --null-- null
Analysis: This query will give no return if not using OPTIONAL.
Sample graph: (to be used for the following examples)

Example: Find 0~2-step outward-transferring paths from the accounts held by C001 to other accounts, carry all properties
UQLn({_id == "C001"}).re({@has}).n({@account}) .re({@transfer})[0:2].n({@account}) as p return p{*}
ResultC001 ----> A001 C001 ----> A001 ----> A003 C001 ----> A001 ----> A003 ----> A004 C001 ----> A001 ----> A004 C001 ----> A001 ----> A004 ----> A002 C001 ----> A002
Analysis: The 0-step in multi-edge template e()[0:N] or e().nf()[0:N] works only when both n() before and after this multi-edge template have same filtering condition.
Example: Find 2-step outward-transferring paths between accounts, with property time ascending along the path, carry all properties
UQLn({@account}).re({@transfer.time > prev_e.time})[2].n({@account}) as p return p{*}
ResultA001 ----> A003 ----> A004
Analysis: Porperty @transfer.time should be loaded to engine (LTE).