query-b7d7df909104cfa2bda86f20dd74d9a0
Should redirects work in a sparql query?Hello, , but the following query returns no results with the former but does show results with the latter. (Q4416090)United States senator redirects to (Q13217683)United States senator It seems that
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 ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?start ?end ?term ?termLabel ?district ?districtLabel ?group ?groupLabel WHERE {
?item p:P39 ?ps .
?ps ps:P39 [ wdt:P279* wd:13217683 ].
OPTIONAL { ?ps pq:P580 ?start }
OPTIONAL { ?ps pq:P582 ?end }
OPTIONAL { ?ps pq:P2937 ?term }
OPTIONAL { ?ps pq:P768 ?district }
OPTIONAL { ?ps pq:P4100 ?group }
#FILTER NOT EXISTS { ?ps pq:P768 [] }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?district"):::projected
v4("?end"):::projected
v7("?group"):::projected
v1("?item"):::projected
v2("?ps")
v3("?start"):::projected
v5("?term"):::projected
a1((" "))
c3(["wd:13217683"]):::iri
c11(["bd:serviceParam"]):::iri
c13(["#91;AUTO_LANGUAGE#93;,en"]):::literal
v1 --"p:P39"--> v2
a1 --"p:direct/P279"--> c3
v2 --"p:statement/P39"--> a1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P580".-> v3
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P582".-> v4
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P2937".-> v5
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P768".-> v6
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:qualifier/P4100".-> v7
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c11 --"wikibase:language"--> c13
end