query-ec7d9b5869e36ab44f9c544278416fe0

rq turtle/ttl

only using the shortest path?I have said query:

Use at

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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#defaultView:Table
SELECT DISTINCT ?item ?itemLabel ?coords ?coordsApprox ?image ?placeLabel ?nature ?natureLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en,fr,de". }
  {
    SELECT DISTINCT ?item (MIN(?coords_) AS ?coords) ?coordsApprox (MIN(?image_) AS ?image) (MIN(?place_) AS ?place) (MIN(?nature_) AS ?nature) WHERE {
      {
        ?item p:P180 ?depict.
        { ?depict (ps:P180/wdt:P31*/wdt:P279*) wd:Q7559. } # dragon
        UNION
        { ?depict (ps:P180/wdt:P31*/wdt:P279*) wd:Q30170627. } # dragon of fiction
      } UNION {
        ?item p:P31 ?nature.
        ?nature (ps:P31/wdt:P279*) wd:Q60985310. # chinese dragon colum
      }

      OPTIONAL { ?item wdt:P276 ?place_. }
      OPTIONAL { ?item wdt:P625 ?coords_. }

      # This optional is used to generate the list of dragon depiction with no coordinates
      OPTIONAL {
        ?item p:P276 ?statement2.
        ?statement2 (ps:P276/wdt:P276*/wdt:P361*) ?place. # TODO: this need to be improved. For example a Louvre wing and the Louvre will both be returned, but we want the most precise info
        ?place wdt:P625 ?coordsApprox.
      }

      OPTIONAL { ?item wdt:P31 ?nature_. }
      OPTIONAL { ?item wdt:P18 ?image_. }

    } GROUP BY ?item ?coordsApprox
    LIMIT 10000
  }
} ORDER BY ?item

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v11("?coords"):::projected v8("?coordsApprox"):::projected v5("?coords_") v2("?depict") v12("?image"):::projected v10("?image_") v1("?item"):::projected v13("?nature"):::projected v9("?nature_") v13("?place") v4("?place_") v6("?statement2") a1((" ")) a2((" ")) a3((" ")) a4((" ")) a5((" ")) a6((" ")) a7((" ")) c4(["#91;AUTO_LANGUAGE#93;,en,fr,de"]):::literal c2(["bd:serviceParam"]):::iri c9(["wd:Q7559"]):::iri c10(["wd:Q30170627"]):::iri c13(["wd:Q60985310"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"p:P31"--> v13 v13 --"p:statement/P31"--> a5 a5 --"p:direct/P279"--> c13 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:P180"--> v2 subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v2 --"p:statement/P180"--> a3 a3 --"p:direct/P31"--> a4 a4 --"p:direct/P279"--> c10 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"p:statement/P180"--> a1 a1 --"p:direct/P31"--> a2 a2 --"p:direct/P279"--> c9 end union1r <== or ==> union1l end end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P276".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P625".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:P276".-> v6 v6 --"p:statement/P276"--> a6 a6 --"p:direct/P276"--> a7 a7 --"p:direct/P361"--> v13 v13 --"p:direct/P625"--> v8 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P31".-> v9 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P18".-> v10 end bind4[/"min(?coords_)"/] v5 --o bind4 bind4 --as--o v11 bind5[/"min(?image_)"/] v10 --o bind5 bind5 --as--o v12 bind6[/"min(?place_)"/] v4 --o bind6 bind6 --as--o v13 bind7[/"min(?nature_)"/] v9 --o bind7 bind7 --as--o v13