query-3c0ad080a5eafa8804a52fa021db7ff2
that returns names of brands with logos and Q-id for the bran owners. I want to be able to find a company by a substring of the label. In the example above you see two commented attempts (you can uncomment them interchangeably) to find companies that have "Mercedes" in their label. They don't return anything. I have had moderate success with the approach below, but it displays many duplicates and I find the one above more elegant.
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?trademark ?trademarkLabel ?image ?organization WHERE {
# find an instance of trademark or any of its subclasses
?trademark wdt:P31/wdt:P279* wd:Q167270.
?trademark rdfs:label ?trademarkLabel.
FILTER(CONTAINS(LCASE(?trademarkLabel), "mercedes"@en)).
# that is owned by an instance of organization
?trademark wdt:P127 ?organization.
?organization wdt:P31/wdt:P279* wd:Q43229.
# and has a logo image
?trademark wdt:P154 ?image.
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?image"):::projected
v3("?organization"):::projected
v2("?trademark"):::projected
v1("?trademarkLabel"):::projected
a1((" "))
a2((" "))
c4(["wd:Q167270"]):::iri
c7(["wd:Q43229"]):::iri
f0[["contains(lower-case(?trademarkLabel),smercedes^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>')"]]
f0 --> v1
v2 --"wdt:P31"--> a1
a1 --"wdt:P279"--> c4
v2 --"rdfs:label"--> v1
v2 --"wdt:P127"--> v3
v3 --"wdt:P31"--> a2
a2 --"wdt:P279"--> c7
v2 --"wdt:P154"--> v4