0

So I recently started using a project that had this SPARQL query. But it wasn't working anymore, can someone please tell me what changes are required. I am using SPARQLWrapper with this endpoint This is the query:

SELECT ?label ?property ?thumbnail WHERE
     { 
             ?entity rdfs:label ?label .
             ?entity wdt:""" + property_code[0] + """ ?property_id .
             ?property_id rdfs:label ?property .
             OPTIONAL { ?property_id wdt:P18 ?thumbnail .}
             FILTER (STR(?label) = '""" + named_entity[0] + """') .
             FILTER (LANG(?property) = "en")
     }

The query gets data according to the property and subject from wikidata. The named_entity[0] is a proper noun

  • what exactly does not work? can you print the query via Python and post the query that is really sent to Wikidata here instead of a source code snippet? – UninformedUser Oct 25 '21 at 06:59
  • Also, I'd highly suggest to avoid things like `FILTER (STR(?label) = '""" + named_entity[0] + """') .` - this is worst case as a full scan on all the labels has to be done. If you know the language, use a proper RDF literal such that the triple store can make used of its index: `FILTER (STR(?label) = '""" + named_entity[0] + """'@en)` – UninformedUser Oct 25 '21 at 07:01

0 Answers0