Search code examples
sparqldbpediawikidata-query-service

Wikidata query equivalent in DBpedia


I am trying to transform my SPARQL query from Wikidata to DBpedia (just for educational purpose), but it doesn't work. Could someone please help me and tell me what I'm doing wrong? Thank you!

In http://query.wikidata.org

SELECT ?musician ?musicianLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    ?musician wdt:P31 wd:Q5 .
    ?musician wdt:P136 ?genre .
    FILTER(?genre IN (wd:Q383982, wd:Q206159))
}
GROUP BY ?musician ?musicianLabel
ORDER BY ASC(?musicianLabel)

working

... and in http://lod.openlinksw.com/sparql

SELECT ?musician WHERE {
    ?musician a <http://dbpedia.org/resource/Person> .
    ?musician <http://dbpedia.org/resource/Genre> <http://dbpedia.org/resource/Genre> .
    FILTER(<http://dbpedia.org/resource/Genre> IN (<http://dbpedia.org/resource/Psychedelic_Pop>, <http://dbpedia.org/resource/Psychedelic_Rock>))
}
GROUP BY ?musician
ORDER BY ASC(?musician)

not working


Solution

  • I'm not sure why you dropped the label from your adapted query... Try this (results)

    SELECT DISTINCT ?musician ?musicianlabel 
    WHERE
     { ?musician a <http://dbpedia.org/ontology/Person> . 
       ?musician <http://dbpedia.org/ontology/genre> ?genre .
       OPTIONAL { ?musician <http://www.w3.org/2000/01/rdf-schema#label> ?musicianlabel . 
                  FILTER ( LANGMATCHES ( LANG ( ?musicianlabel ), 'en' ) ) 
                }
       FILTER (?genre IN ( <http://dbpedia.org/resource/Psychedelic_pop> , 
                           <http://dbpedia.org/resource/Psychedelic_rock>
                         )
              )
     } 
    ORDER BY ASC ( ?musician )