sparqlwikidatafederated-queries

Using Wikidata label service in federated queries


I'm wondering if it is possible to use Wikidata label service in a federated query. E.g., the following query

# Query from a local SPARQL enpoint

select ?item ?itemLabel
where {
    SERVICE <https://query.wikidata.org/sparql> {
        ?item wdt:P31 wd:Q146.
        SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }

}

returns empty ?itemLabels. How can I get also ?itemLabels in my resultset?


Solution

  • You could also use the manual mode, it's just one line more in your case:

    PREFIX       wdt:  <http://www.wikidata.org/prop/direct/>
    PREFIX        wd:  <http://www.wikidata.org/entity/>
    PREFIX        bd:  <http://www.bigdata.com/rdf#>
    PREFIX  wikibase:  <http://wikiba.se/ontology#>
    PREFIX      rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    
    SELECT * {
      SERVICE <https://query.wikidata.org/sparql> {
        ?item wdt:P31 wd:Q146
        SERVICE wikibase:label { bd:serviceParam wikibase:language "it". ?item rdfs:label ?label }
      }
    }
    

    Try on FactForge