--- tags: - woql - reference - path-queries title: TerminusDB Path Query Reference Guide nextjs: metadata: title: TerminusDB Path Query Reference Guide description: A reference guide to path queries in TerminusDB. keywords: terminusdb, datalog, find, graph traversal, path, path query, query, relationships openGraph: images: https://assets.terminusdb.com/docs/technical-documentation-terminuscms-og.png alternates: canonical: https://terminusdb.com/docs/path-query-reference-guide/ media: [] --- This page documents path query syntax — a concise way to express multi-hop graph traversals in WOQL. Path queries let you follow chains of relationships (e.g., "find all ancestors" or "shortest path between two nodes") without writing recursive joins manually. They use a regular-expression-like syntax over property names. > For guidance on back-links and path queries using GraphQL visit the [GraphQL reference guide](/docs/graphql-query-reference/#backlinks) The syntax of path expressions, for expressions `A`, `B` and fields `F` is as follows: {% table %} - Expression - Example - Name - Description --- - `A,B` - `friend,name` - Sequence - First follow expression `A`, then from that node expression `B` --- - `A|B` - `friend|foe` - Choice - Follow expression `A` or expression `B` --- - `F+` - `friend+` - Plus - Follow the field `F` any number of times, but at least once --- - `F*` - `friend*` - Star - Follow the field `F` any number of times, including zero --- - `.` - `.` - Any - Follow any field regardless of name --- - `F` - `friend` - Field - Follow the field `F` --- - `F{n,m}` - `friend{1,3}` - Times - Follow the field `F` between `n` and `m` times --- - `(A)` - `(friend|foe)` - Group - Group the expression for inclusion in a larger expression --- - `F>` - `friend>` - Forward - Follow the field `F` forward. This is the same as `F`. --- - `