简体   繁体   中英

SPARQL - write a query to get uris refering to DBpedia ontology

My current query looks like this:

SELECT DISTINCT ?pred WHERE {
  ?pred a rdf:Property
}
ORDER BY ?pred

which returns predicates like http://dbpedia.org/ontology/birthYear and http://dbpedia.org/property/abandoned . How may I modify my query in order to get results with the prefix " http://dbpedia.org/ontology/ " only?

@AKSW provided one possible solution in comments, which may indeed get you what you want --

SELECT ?pred 
WHERE
 { VALUES ?type {owl:ObjectProperty owl:DatatypeProperty } 
   ?pred a ?type
 }
ORDER BY ?pred

That said, your question was specific in a way not answered by the above, so possibly this might be what you want --

SELECT ?pred 
WHERE
 { 
   ?pred a rdf:Property
   FILTER ( REGEX ( STR (?pred), "http://dbpedia.org/ontology/", "i" ) )
 }
ORDER BY ?pred 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM