I have problems with using the OPTIONAL phrase in the SPARQL statements. When I’m quering dbpedia like this:
CONSTRUCT { ?guitarist rdfs:label ?name . ?guitarist rdfs:comment ?desc . ?guitarist dbpprop:placeOfBirth ?placebirth }
WHERE {
?guitarist dbpprop:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_musical_artist> .
?guitarist rdfs:label ?name .
?guitarist rdfs:comment ?desc .
?guitarist dbpprop:placeOfBirth ?placebirth .
FILTER ( lang(?name) = "en" && lang(?desc) = "en" )
}
Roger Waters birthplace and other data are returned. But when I turn it to this, all Roger_Waters records are missing:
CONSTRUCT { ?guitarist rdfs:label ?name . ?guitarist rdfs:comment ?desc . ?guitarist dbpprop:placeOfBirth ?placebirth }
WHERE {
?guitarist dbpprop:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_musical_artist> .
?guitarist rdfs:label ?name .
?guitarist rdfs:comment ?desc .
OPTIONAL { ?guitarist dbpprop:placeOfBirth ?placebirth }
FILTER ( lang(?name) = "en" && lang(?desc) = "en" )
}
What I’m doing wrong – I suppose the complete records not to be missing after applying OPTIONAL…
The DBpedia endpoint returns partial results for queries that it deems too expensive.
Doing a
SELECT COUNT(*) WHERE …with these two queries, it looks like the first query should return 8k results and the second should return 60k results. YourCONSTRUCTshould generate 2-3 triples per result, so the first query should yield 16-24k triples, and the second should yield 120-180k. When I run the queries, I get the curious number of exactly 10001 triples from either query. So clearly the results are truncated.Try
LIMITandOFFSET(possibly with anORDER BY).