0

I would like to query wikidata in order to obtain entries based_on some technologies (blockchain, solid, RDF and so on). These potential technologies would change dynamically, so that, I inject them as literals from a piece of code. The point is that I get no results when trying injecting literals (strings).

In the next piece of SPARQL, you can see five different approaches I tried (all of them fail), through https://query.wikidata.org/

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX xsd: <www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?item 
WHERE { 
#test1    ?item wdt:P144 ?o FILTER (str(?o) = 'blockchain' ) .
#test2    ?item wdt:P144 ?o FILTER (regex (?o,'blockchain')) .
#test3    ?item wdt:P144 ?o FILTER (regex (?o,'^blockchain$')) .
#test4    ?item wdt:P144 'blockchain'  .
#test5    ?item wdt:P144 "blockchain"  .
}

Any clue? Thx in advance for your time and support.

logi-kal
  • 7,107
  • 6
  • 31
  • 43
David G. Hdez
  • 125
  • 1
  • 8
  • the values of `wdt:P144` are Wikidata entites, thus, the values of `?o` are URIs like `wd:123` or whatever. It's obvious that a string filter on those URIs doesn't match – UninformedUser Jan 12 '20 at 09:26
  • 1
    `SELECT ?item WHERE { ?item wdt:P144 ?o . ?o rdfs:label ?ol FILTER (lang(?ol) = 'en') FILTER(contains(str(?ol),'blockchain' ))}` – UninformedUser Jan 12 '20 at 09:28
  • alternative with entity search API: `SELECT ?item WHERE { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "EntitySearch" . bd:serviceParam wikibase:endpoint "www.wikidata.org" . bd:serviceParam mwapi:search "blockchain" . bd:serviceParam mwapi:language "en" . ?o wikibase:apiOutputItem mwapi:item . ?num wikibase:apiOrdinal true . } ?item wdt:P144 ?o } ORDER BY ASC(?num) LIMIT 20` – UninformedUser Jan 12 '20 at 09:32
  • Thanks a lot for the answer @AKSW. It make full sense. Do you get a blog, or youtube channel where follwing you – David G. Hdez Jan 13 '20 at 12:11

0 Answers0