Search code examples
sparqldbpedia

SPARQL Query for all Books by George Orwell


I created this query to return all books that are notable works by George Orwell but it returns no result.

PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbp: <http://dbpedia.org/resource/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>

SELECT ?name ?title where {
   ?person foaf:name ?name .
   ?title dbo:author ?person .
   ?title dbo:notableWork dbp:George_Orwell .
}

I cannot seem to figure out why there is no result.

I am running the query in http://dbpedia.org/snorql


Solution

  • Don't you have the triples about notable works in the wrong order?

    Try rewriting based on this working query

    SELECT * 
    WHERE {
    :George_Orwell dbo:notableWork ?title 
    }
    

    .

    title
    :Nineteen_Eighty-Four
    :Animal_Farm
    

    You can also bind :George_Orwell to a variable and ask more about that:

    SELECT * 
    WHERE {
    values ?author { :George_Orwell } .
    ?author rdfs:label ?l .
    ?title ?p ?author .
    ?title rdf:type  dbo:Book .
    filter (lang(?l) = "en")
    }
    

    and DESCRIBE things

    describe :Animal_Farm