Finding or Filtering on Topic Properties

Top  Previous  Next

Retrieving Topic Property Values

Topic properties can be retrieved referring to the topic property schema type as the predicate of a triple. For example to return each person (defined by the subject identifier http://psi.networkedplanet.com/types/person) with their age (defined by the type http://psi.networkedplanet.com/types/age) you can use the following query:

PREFIX ont: <http://psi.networkedplanet.com/types/>
SELECT ?p ?age {
  ?p a ont:person .
  ?p ont:age ?age
}

Finding Topics by Topic Property Value

SPARQL filters are also supported in queries. So to find all people over the age of 21:

PREFIX ont: <http://psi.networkedplanet.com/types/>
SELECT ?p ?age {
  ?p a ont:person .
  ?p ont:age ?age .
  FILTER { ?age > 21 }
}

Sorting Results by Topic Property Value

Property values can also be used for sorting results using the SPARQL ORDER BY (DESC) construct. The following example shows a query for all people over the age of 21 with the result topics ordered by age from oldest to youngest.

PREFIX ont: <http://psi.networkedplanet.com/types/>
SELECT ?p ?age {
  ?p a ont:person .
  ?p ont:age ?age .
  FILTER { ?age > 21 }
}
ORDER BY DESC (?age)