For this query, you can also use the regular Wikibase search, either skipping the query service completely –
https://www.wikidata.org/wiki/Special:Search/haswbstatement:P31=Q2085381 inlabel:simon@en https://www.wikidata.org/wiki/Special:Search/haswbstatement:P31=Q2085381 inlabel:simon@en https://www.wikidata.org/w/api.php?action=query&list=search&srsearch...
– or combining the query service with the search API via MWAPI https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/MWAPI:
SELECT ?publisher ?publisherLabel WHERE { SERVICE wikibase:mwapi { bd:serviceParam wikibase:api "Search"; wikibase:endpoint "www.wikidata.org"; mwapi:srsearch "haswbstatement:P31=Q2085381 inlabel:simon@[AUTO_LANGUAGE]". ?publisher wikibase:apiOutputItem mwapi:title. } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }
On 01.06.19 11:51, Thad Guidry wrote:
Found my answer !!! had to go back to the SPARQL Tutorial page and re-read the section on FILTER https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial#FILTER...specifically...
The label service is very useful if you just want to display the label of a variable. *But if you want to do stuff with the label** *...
yes, I do want to have an expression about a label..., in fact, 95% of the time that's what I want to do...so why doesn't the darn label service help me do that better?
The reason why this doesn’t work is that the label service adds its variables very late during query evaluation; at the point where we try to filter on |?humanLabel|, the label service hasn’t created that variable yet. Fortunately, the label service isn’t the only way to get an item’s label. Labels are also stored as regular triples, using the predicate |rdfs:label|. Of course, this means all labels, not just English ones; if we only want English labels, we’ll have to filter on the language of the label:
AH ! label service does things AFTER the query returns results.
So this works, and is how you actually handle label filtering *without* using the label service, and instead getting the label stored as a triple (and it's twice as fast as well)...
SELECT ?publisher ?label WHERE { ?publisher wdt:P31 wd:Q2085381; rdfs:label ?label. FILTER(LANG(?label) = "[AUTO_LANGUAGE]"). FILTER CONTAINS(LCASE(?label), "simon"). }
Thad https://www.linkedin.com/in/thadguidry/
Wikidata mailing list Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata