I have links to a number of DBpedia pages like:
http://dbpedia.org/resource/Harry_Potter
http://dbpedia.org/resource/Twilight_(series)
http://dbpedia.org/resource/Bible
http://dbpedia.org/resource/Manga
I would like to get the Abstract and Thumbnail entities for each one of them.
I can get them individually using:
For Abstract:
PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX res: <http://dbpedia.org/resource/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label WHERE { <http://dbpedia.org/resource/Harry_Potter> dbo:abstract ?label . FILTER (lang(?label) = \'en\')}
For Thumbnail:
PREFIX dbo: <http://dbpedia.org/ontology/> PREFIX res: <http://dbpedia.org/resource/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?thumbnail WHERE { <http://dbpedia.org/resource/Harry_Potter> dbo:thumbnail ?thumbnail}
Is it possible to combine the above two queries into a single one. I am very new to SPARQL and couldn't get it to work.
Additionally, is there a better way to query than my current approach?
Of course it's possible to combine them, the trivial way to do it would be just to concatenate the bodies of the two
WHERE
s and adjust theSELECT
accordingly:If you want to be more succinct, you can combine two triples with the same subject using
;
:And since you defined the
res:
prefix, you can use that to shorten the URI: