What is a Property Path?

A property path is an element of the SPARQL query language that allows the user to query for complex paths between nodes instead of being limited to adjoining neighbours each time. Property paths expand the capabilities of SPARQL to matching graph patterns of indeterminate length and providing multiple alternatives. The extent of the usefulness of this feature becomes much clearer when seen in an example.

Briefly before diving in, to understand the examples the key aspects to property path notation are as follows:

“/” means combine two properties in a chain

“+” means repeat the same property 1 or more times

“|” is the symbol for “or”

:Jane :hasFriend/:hasAge ?age

Will return the ages of all of Jane’s friends, hiding the joining step of the friends themselves.

:Mike :hasParent+ ?ancestor

Will return all of Mike’s ancestors (parents, parents’ parents, parents’ parents’ parents, and so on)

?product a :Product;
:hasDescription|:hasInfo|:hasText ?description

Will return the descriptions of all products even if our data comes from different sources using different predicate lables.

Down arrow icon.