query-8f5630fe229a5a894f0d1e4f616a27bf
clarifying mul usage to illustrate how mul would be the universal, nl the specific. How can I optimise this query to reduce the number of wikibase and FILTER commands, using all the techniques I can think of. Hopefully this can be the basis of an Example Query. (P1448)official name is a ship with a Dutch prefix Hr.Ms., and a different prefix HNLMS everyone else in the world uses. So as well as the conventional labels, I've used mul and nl in its (Q2189292)HNLMS Tonijn I'm still trying to get my head round mul. For example
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
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#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?english ?native ?keyword WHERE {
SERVICE wikibase:label {bd:serviceParam wikibase:language "en,nl,mul"}
VALUES ?item {wd:Q2189292}
OPTIONAL {?item wdt:P31 ?k. ?k rdfs:label ?keyword. FILTER (LANG(?keyword) = "en")}
SERVICE wikibase:label {bd:serviceParam wikibase:language "en,nl". ?item rdfs:label ?english}
OPTIONAL {?item wdt:P1448 ?officialnl. FILTER (lang(?officialnl) = "nl")} # official name
OPTIONAL {?item wdt:P1448 ?officialmul. FILTER (lang(?officialmul) = "mul")} # official name
BIND(COALESCE(?officialnl,?officialmul) AS ?native)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?english"):::projected
v4("?item"):::projected
v5("?k")
v3("?keyword"):::projected
v7("?native"):::projected
v1("?officialmul")
v2("?officialnl")
c10(["en,nl"]):::literal
c5(["bd:serviceParam"]):::iri
c7(["en,nl,mul"]):::literal
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c7
end
bind0[/VALUES ?item/]
bind0-->v4
bind00(["wd:Q2189292"])
bind00 --> bind0
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P31".-> v5
v5 --"rdfs:label"--> v3
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c10
v4 --"rdfs:label"--> v6
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P1448".-> v2
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v4 -."wdt:P1448".-> v1
end
bind1[/"?officialnl?officialmul"/]
v2 --o bind1
v1 --o bind1
bind1 --as--o v7