A SPARQL Property Path is a regular expression-like pattern applied to RDF predicates to match chains of relationships of arbitrary length in a single, compact query clause. This syntax extends Basic Graph Patterns by allowing operators like sequence (/), alternation (|), and repetition (*, +, ?) to traverse the graph. It eliminates the need for verbose, recursive query constructs, enabling efficient discovery of transitive relationships like organizational hierarchies or network connectivity.
Glossary
SPARQL Property Paths

What are SPARQL Property Paths?
SPARQL Property Paths are a concise syntax within the SPARQL query language for matching arbitrary-length paths in an RDF graph using regular expression-like patterns over predicates.
Property Paths are evaluated through graph traversal, where the SPARQL engine follows the defined pattern from a starting node to find all reachable nodes. Key operators include inverse (^) for following a link backwards, negation (!) for path exclusion, and fixed-length ranges ({n,m}). This functionality is fundamental for semantic reasoning and complex knowledge graph queries, providing a powerful tool for data exploration and inference that is more expressive than simple triple matching.
Core Property Path Operators
SPARQL Property Paths extend basic graph pattern matching with a concise, regular expression-like syntax for traversing arbitrary-length paths through an RDF graph. These operators allow complex multi-hop relationships to be queried with a single, declarative pattern.
Sequence Path (`/`)
The forward slash (/) operator specifies a sequence of properties. It matches a path where the subject is connected to the final object via a chain of intermediate nodes, following the specified predicates in order.
- Example:
:person :parent/:siblingfinds a person's parent's sibling (i.e., an aunt or uncle). - This is the fundamental operator for composing multi-step relationships.
- It is analogous to concatenation in regular expressions or path traversal in file systems.
Alternative Path (`|`)
The pipe (|) operator specifies an alternative between two or more properties. It matches a path where the subject is connected to the object via any one of the listed predicates.
- Example:
:document :creator|:contributormatches resources that are either the creator or a contributor of a document. - This operator provides flexibility for querying heterogeneous data models where relationships may be expressed with different predicates.
- It is analogous to the alternation operator in regular expressions.
Inverse Path (`^`)
The caret (^) operator specifies the inverse of a property path. It traverses a predicate in the reverse direction, from object to subject.
- Example:
:employee ^:worksForfinds all entities that have:worksForpointing to the employee (e.g., the companies that employ them). - Example:
:alice :knows/^:knowsfinds people known by someone Alice knows (a two-way friendship path). - This operator is essential for navigating graphs where relationships are not always stored in the desired query direction.
Zero-or-One Path (`?`)
The question mark (?) operator makes a path optional, matching zero or one occurrence of the path. It is the zero-or-one modifier.
- Example:
:person :hasDegree?matches persons, returning those with a degree and those without (binding the object only if present). - This is useful for matching sparse or incomplete data without requiring a
OPTIONALclause for a simple property. - It directly corresponds to the
?quantifier in regular expressions.
Zero-or-More Path (`*`) & One-or-More Path (`+`)
The Kleene star (*) and plus (+) operators match paths of arbitrary length.
*matches zero or more repetitions.+matches one or more repetitions.
Key Use Cases:
- Transitive Closure:
:component :partOf+finds all super-components (direct and indirect). - Variable-Length Relationships: Finding all descendants in a hierarchy (
:parent*). - These operators enable recursive graph traversal without predefined depth limits, a core feature distinguishing property paths from chained basic graph patterns.
Negated Property Set (`!`)
The exclamation mark (!) operator defines a negated property set. It matches a path where the connecting predicate is not one of the listed properties.
- Syntax: Can negate a single property (
!:knows), a disjunction (!(:knows|:worksWith)), or the inverse of properties (!^:parent). - Example:
:entity !rdf:type ?valuefinds all properties of an entity except its type. - This operator is powerful for filtering out specific relationships during path traversal, supporting more precise and expressive queries.
How SPARQL Property Paths Work
SPARQL Property Paths provide a concise syntax for matching arbitrary-length paths in an RDF graph using regular expression-like patterns over predicates.
A SPARQL Property Path is a regular expression-like syntax for concisely matching chains of predicates (relationships) of arbitrary length in an RDF graph. It extends the basic graph pattern matching of SPARQL, allowing queries to traverse one or more intermediate nodes without explicitly naming them. Core operators include sequence (/), alternation (|), and Kleene star (*) for zero-or-more repetitions. This enables efficient expression of queries for transitive relationships, such as finding all subclasses within a hierarchy or all connections in a social network.
Property paths are evaluated by the SPARQL engine, which performs graph traversal to find all paths matching the specified pattern. They are a declarative feature; the query specifies what to find, not how to traverse the graph, leaving optimization to the underlying triplestore. Key use cases include inference over RDFS and OWL constructs (like rdfs:subClassOf*) and simplifying queries that would otherwise require verbose unions or recursive subqueries. They are integral to querying complex enterprise knowledge graphs where relationships form deep, interconnected networks.
Practical Query Examples
SPARQL Property Paths use a regular expression-like syntax to match arbitrary-length chains of predicates in an RDF graph. These examples demonstrate their power for concise and expressive graph traversal.
Direct and Inverse Paths
Property paths allow you to traverse edges in either direction. The ^ operator navigates the inverse of a predicate.
- Direct Path:
:parentmatches the:parentproperty. - Inverse Path:
^:parentmatches from a child to its parent.
Example Query: Find all people who are someone's parent.
sparqlSELECT ?parent WHERE { ?parent ^:parent ?child . }
This is equivalent to the more verbose basic graph pattern: ?child :parent ?parent .
Alternative Paths
The | (alternation) operator matches one of several possible predicates, acting as a logical OR for graph edges.
- Path Syntax:
:mother|:fathermatches either a:motheror a:fatherrelationship.
Example Query: Find all of a person's direct biological parents.
sparqlSELECT ?parent WHERE { :Alice :mother|:father ?parent . }
This concisely replaces a UNION of two triple patterns, simplifying queries for disjunctive relationships.
Sequence Paths
The / operator chains predicates together to match a specific sequence of relationships.
- Path Syntax:
:partOf/:locatedInfirst matches a:partOfedge, then from that node, a:locatedInedge.
Example Query: Find the location of a component by traversing through its assembly.
sparqlSELECT ?location WHERE { :Engine_123 :partOf/:locatedIn ?location . }
This query finds the location of the assembly that contains :Engine_123, a common pattern for navigating hierarchical or composite structures.
Zero-or-One and Zero-or-More
The ? and * operators match paths of variable length, crucial for navigating flexible hierarchies.
- Zero-or-One (
?)::knows?matches either one:knowsedge or no edge at all (the current node). - Zero-or-More (
*)::partOf*matches any chain of:partOfrelationships, including zero (transitive closure).
Example Query: Find all parts and sub-parts of a component.
sparqlSELECT ?part WHERE { :Airframe_1 :partOf* ?part . }
This returns :Airframe_1 itself (zero-length path) and every part reachable via any number of :partOf links.
One-or-More and Specific Length
The + operator and {n,m} ranges provide precise control over path repetition.
- One-or-More (
+)::supervises+matches a chain of one or more:supervisesrelationships (direct and indirect reports). - Exact Range (
{n})::translatedBy{2}matches exactly two:translatedByhops (e.g., English -> French -> German).
Example Query: Find all indirect subordinates of a manager.
sparqlSELECT ?subordinate WHERE { :CTO :supervises+ ?subordinate . }
This excludes the CTO themselves (unlike *) and retrieves everyone in their reporting chain.
Negated Property Sets
Negation via ! allows matching paths that do not use specific predicates, useful for exclusionary searches.
- Negated URI:
!rdf:typematches any predicate that is notrdf:type. - Negated Set:
!(:mother|:father)matches any predicate except:motheror:father.
Example Query: Find all relationships from a person that are not familial.
sparqlSELECT ?relation ?other WHERE { :Bob !(:mother|:father|:spouse|:child) ?other . BIND(str(?p) AS ?relation) }
This filters out standard family predicates, potentially revealing :worksWith, :knows, or other connections.
Property Paths vs. Basic Graph Patterns
A comparison of the two primary mechanisms for traversing relationships in an RDF graph within a SPARQL query.
| Feature / Characteristic | Basic Graph Pattern (BGP) | SPARQL Property Path |
|---|---|---|
Core Syntax | Conjunction of triple patterns: | Regular expression-like path operators: |
Path Length Matching | Fixed, explicit length. Each hop requires a separate triple pattern and variable. | Arbitrary or variable length. Can match paths of zero, one, or more hops with a single pattern. |
Intermediate Node Capture | ||
Result Binding | Binds variables for every node and edge in the matched pattern. | Binds variables only for the start and end nodes of the matched path. |
Expressiveness for Complex Paths | ||
Query Conciseness | Verbose for long or recursive paths. | Extremely concise for path expressions. |
Performance Profile | Predictable, akin to relational joins. Optimizable via standard indexes. | Can be computationally intensive for unbounded paths ( |
Use Case Primacy | Exact, detailed pattern matching where all graph components are needed. | Finding connections and reachability, where only the endpoints matter. |
Inverse Traversal | Requires explicit triple pattern with inverse predicate or variable. | Uses the |
Alternatives / Disjunction | Requires UNION of multiple BGPs. | Uses the |
Negated Paths | Not directly supported. | Uses |
Frequently Asked Questions
SPARQL Property Paths provide a concise, regular expression-like syntax for matching arbitrary-length sequences of relationships (predicates) in an RDF graph. This FAQ addresses common questions about their syntax, use cases, and performance.
A SPARQL Property Path is a syntactic feature of the SPARQL query language that allows for concise matching of sequences of predicates (relationships) in an RDF graph, using operators inspired by regular expressions. Instead of writing multiple, verbose triple patterns or complex nested queries to traverse a chain of unknown length, a property path expresses the traversal pattern in a single, compact expression. The SPARQL processor evaluates the path by recursively exploring the graph from a starting node, following predicates that match the specified pattern, to find reachable ending nodes. This enables queries like "find all ancestors" or "find resources connected by any sequence of managerial relationships" without explicitly defining the number of steps.
Core Syntax Examples:
:parent+(One or more:parentrelationships):knows/:worksAt(A:knowsrelationship followed by a:worksAtrelationship):partOf|:subComponentOf(Either a:partOfor a:subComponentOfrelationship)^:supervises(The inverse of the:supervisesrelationship)
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
SPARQL Property Paths are a powerful extension of the SPARQL query language, enabling concise, regular expression-like navigation of RDF graph structures. The following concepts are essential for understanding and effectively utilizing this feature.
Basic Graph Pattern (BGP)
A Basic Graph Pattern (BGP) is the fundamental matching unit in a SPARQL query, consisting of a set of triple patterns that must all be satisfied in the data graph. Property Paths extend BGPs by allowing more expressive path patterns between subjects and objects, rather than requiring explicit intermediate nodes and predicates. For example, the BGP ?person :knows ?friend . ?friend :knows ?friendOfFriend can be condensed into a single Property Path: ?person :knows/:knows ?friendOfFriend.
RDF Triple
An RDF triple is the atomic data unit of the Resource Description Framework, structured as a subject-predicate-object statement. Property Paths operate over the predicate component, defining patterns that sequences of these triples must follow. Understanding the triple structure is crucial because a Property Path like :parentOf+ matches a chain of one or more consecutive :parentOf triples, navigating from a subject through intermediate subjects/objects to a final object.
SPARQL
SPARQL is the standard query language for RDF data. Property Paths are a syntactic feature within SPARQL 1.1, integrated into the WHERE clause's graph pattern matching. They enhance SPARQL's expressiveness for traversing graph neighborhoods without complex joins or recursive subqueries. Key query forms like SELECT, CONSTRUCT, and ASK can all utilize Property Paths to find, build, or check for the existence of specific graph paths.
Triplestore
A triplestore is a specialized database engineered for storing and querying collections of RDF triples. The efficient execution of SPARQL Property Path queries is a critical capability of modern triplestores. Performance varies based on the path operator used (e.g., transitive closure * vs. negation !) and the underlying indexing strategies. Triplestores like GraphDB, Stardog, and Virtuoso implement optimizations for evaluating these recursive or alternative path patterns.
Cypher Query Language
Cypher is the declarative query language for the property graph model (e.g., Neo4j). It provides analogous path-finding capabilities using a distinct syntax. While SPARQL Property Paths use regular expression operators on predicates (:knows*), Cypher uses a relationship pattern syntax within square brackets ([:KNOWS*]). Comparing these highlights the semantic difference between RDF's global property semantics and property graphs' localized relationship types.
RDF-star / RDF*
RDF-star is an extension to RDF that allows triples themselves to be subjects or objects of other triples, enabling native annotation of statements. Property Paths can navigate through these nested graph structures. For instance, a path could be used to find the provenance chain of assertions about a statement. This combines concise path navigation with the ability to query complex metadata about graph edges.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us