Property Paths

SPARQL property paths enable users to examine the patterns between properties in the data. Property paths reveal the routes between nodes in a graph.

Property Path Syntax

Specify property paths in the predicate part of a triple pattern. Combine predicates using the operators described in the table below. For more information, see the W3C Property Path specification.

Construct Property Path Expression Name Description
<URI> PredicatePath A predicate URI in a triple pattern matches a path length of one.
^path1 InversePath Matches on backwards paths--subject to object.
path1/path2 SequencePath Matches on forward paths--path1 followed by path2.
path1|path2 AlternativePath Matches on either path1 or path2. AnzoGraph finds all possibilities.
path1* ZeroOrMorePath Connects the subject and object of the path by zero or more matches of path1, i.e., path1 repeated zero or more times.
path1+ OneOrMorePath Connects the subject and object of the path by one or more matches of path1, i.e., path1 repeated one or more times.
path1? ZeroOrOnePath Connects the subject and object of the path by zero or one matches of path1, i.e., path1 is optional.
(path) N/A Specifies groups of paths. Use parentheses around groups to control precedence.
!URI
or
!(URI1|...|URIn)
NegatedPropertySet A negated property path where matches are excluded. The order of URIs is not significant.
!^URI
or
!(^URI1| ...|^URIn)
NegatedPropertySet Negated property path where the excluded matches are based on a reversed path. The order of URIs is not significant.
You can include a combination of forward and reverse properties in a negated property set: !(URI1|...|URIj|^URIj+1|...|^URIn)