Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

confusing OPTIONAL - disappearing records

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...

like image 408
deha Avatar asked Nov 20 '25 10:11

deha


1 Answers

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. Your CONSTRUCT should 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 LIMIT and OFFSET (possibly with an ORDER BY).

like image 152
cygri Avatar answered Nov 22 '25 03:11

cygri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!