How can I query Wikidata to get all items that have labels contain a word? I tried this but didn\'t work; it retrieved nothing.
SELECT ?item ?itemLabel WHERE {
As of today (June 2020), the best way to do this seems to be using these CirrusSearch extensions. The following does a substring search in all English labels and comes back with 10,000 results in <20 seconds. I believe it also searches in aliases and descriptions.
SELECT DISTINCT ?item ?label
WHERE
{
SERVICE wikibase:mwapi
{
bd:serviceParam wikibase:endpoint "www.wikidata.org";
wikibase:api "Generator";
mwapi:generator "search";
mwapi:gsrsearch "inlabel:city"@en;
mwapi:gsrlimit "max".
?item wikibase:apiOutputItem mwapi:title.
}
?item rdfs:label ?label. FILTER( LANG(?label)="en" )
}