Search code examples
sparqlwikidatawikidata-apiwikidata-query-service

Fail to retrieve a wikidata item through SPARQL


I tried to search and get the ID of a item with a certain label: Teodor Bogdanov. I can search this name successfully through wikidata website. However, I failed to do so by searching through SPARQL. The code is here.

I also copied it here:

SELECT distinct ?item ?itemLabel ?itemDescription WHERE{  
  ?item ?label "Teodor Bogdanov".
}

The same thing happens for Félix Anaut

Could anyone help me fix this issue? Thank you in advance.


Solution

  • THere are two issues in your query. The predicate in your triple pattern is a variable, while it should be a constant, rdfs:label. It asks about all items and properties linked to "Teodor Bogdanov". The second issue is the missing language tag. When these two are fixed, you get the following query

    SELECT distinct ?item  {
      ?item rdfs:label "Teodor Bogdanov"@en .
    }
    

    For "Félix Anaut", while this spelling with an acute accent is used in English Wikipedia, that's not the case in Wikidata.