query-dfd37cc7794009829674399480227a05

rq turtle/ttl

Federation with correlation - Get byline for Commons images

Run this from WCQS - https://commons-query.wikimedia.org/

SELECT ?exoplanet ?label_en ?image ?file ?creator_ns ?creator_wu ?creator_url WHERE { hint:Query hint:optimizer "None" . SERVICE https://query.wikidata.org/sparql { ?exoplanet wdt:P31 wd:Q44559 ; wdt:P18 ?image . OPTIONAL { ?exoplanet rdfs:label ?label_en . FILTER(LANG(?label_en)="en") } } ?file schema:url ?image . OPTIONAL { ?file p:P170 ?cst . OPTIONAL { ?cst pq:P2093 ?creator_ns . } OPTIONAL { ?cst pq:P4174 ?creator_wu . } OPTIONAL { ?cst pq:P2699 ?creator_url . } } }

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
# Federation with correlation - Get byline for Commons images
# Run this from WCQS - https://commons-query.wikimedia.org/
SELECT ?exoplanet ?label_en ?image ?file ?creator_ns ?creator_wu ?creator_url
WHERE {

  SERVICE <https://query.wikidata.org/sparql> {
    ?exoplanet wdt:P31 wd:Q44559 ;
      wdt:P18 ?image .
    OPTIONAL { ?exoplanet rdfs:label ?label_en . FILTER(LANG(?label_en)="en") }
  }
  ?file schema:url ?image .
  OPTIONAL {
    ?file p:P170 ?cst .
    OPTIONAL { ?cst pq:P2093 ?creator_ns . }
    OPTIONAL { ?cst pq:P4174 ?creator_wu . }
    OPTIONAL { ?cst pq:P2699 ?creator_url . }
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?creator_ns"):::projected v8("?creator_url"):::projected v7("?creator_wu"):::projected v5("?cst") v2("?exoplanet"):::projected v4("?file"):::projected v3("?image"):::projected v1("?label_en"):::projected c4(["wd:Q44559"]):::iri subgraph s1["https://query.wikidata.org/sparql"] style s1 stroke-width:4px; v2 --"p:direct/P31"--> c4 v2 --"p:direct/P18"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."rdfs:label".-> v1 end end v4 --"schema:url"--> v3 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:P170".-> v5 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P2093".-> v6 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P4174".-> v7 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:qualifier/P2699".-> v8 end end