1

I want to obtain a list of "is [property] of" items.

For example, Barack Obama on DBPedia has both "successor" as property and "is successor of" properties (with different successors!).

The first I can get with the following SPARQL query:

PREFIX ont: <http://dbpedia.org/ontology/>
PREFIX obama: <http://dbpedia.org/resource/Barack_Obama>
SELECT ?successor
WHERE{  
    obama: ont:successor ?successor
}  

How, can I get the list of items that satisfy "is successor of" criteria?

Max Li
  • 5,069
  • 3
  • 23
  • 35
  • the "is property of "jsut means the triple goes inteh other direction. if you see "X is [p] of Y", you'd query with "?y p ?x". – Joshua Taylor Apr 16 '15 at 10:35

1 Answers1

2

If you look closely, most of the is [property] of are defined as a has [property]. For example, the is successor of is defined as predecessor. Thus in your case you need to change your query to:

PREFIX obama: <http://dbpedia.org/resource/Barack_Obama>
SELECT *
WHERE{  
    obama: dbpprop:predecessor ?successor
}

Just explore the main properties of DBpedia and such things pop out. Or as Jashua mentioned change the direction of the query:

PREFIX obama: <http://dbpedia.org/resource/Barack_Obama>
SELECT *
WHERE{  
      ?successor dbpprop:successor obama:
}
Artemis
  • 3,271
  • 2
  • 20
  • 33
  • This problem is the same issue as mentioned in [a previous question](http://stackoverflow.com/q/28765205/1281433) (one where you posted the accepted answer, actually). Since the issue is the same (when we see "X [is P of] Y", the pattern needs to be "?y p ?x"), I think it probably would have made more sense to flag as a duplicate. – Joshua Taylor Apr 16 '15 at 10:39
  • I saw the flag after I posted the answer. True enough! – Artemis Apr 16 '15 at 10:40