query-05afc988a20a15fc6f9e1275e6251ec2

rq turtle/ttl

Find items that use specific files. I come up with the following query: c:Category:Graves_without_Wikidata_item files from (P18)image Hi, I am trying to find items that include in

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?file ?item {
  SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
     bd:serviceParam mwapi:gcmtitle "Category:Graves_without_Wikidata_item" .
     bd:serviceParam mwapi:generator "categorymembers" .
     bd:serviceParam mwapi:gcmtype "page" .
     bd:serviceParam mwapi:gcmlimit "max" .
     bd:serviceParam mwapi:gcmsort "timestamp" .
     bd:serviceParam mwapi:gcmdir "descending" .
     ?file wikibase:apiOutput mwapi:title  .
  }
  BIND(substr(?file,6) as ?fileName) .
  OPTIONAL { 
    ?item wdt:P18 ?fileName .
   }
#  ?item wdt:P31 wd:Q173387 .
#  ?item wdt:P195 wd:Q311 .
  FILTER ( BOUND(?item) ) .
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?file"):::projected v3("?fileName") v1("?item"):::projected c14(["max"]):::literal c18(["descending"]):::literal c10(["categorymembers"]):::literal c2(["bd:serviceParam"]):::iri c8(["Category:Graves_without_Wikidata_item"]):::literal c12(["page"]):::literal c20(["mwapi:title"]):::iri c6(["commons.wikimedia.org"]):::literal c4(["Generator"]):::literal c16(["timestamp"]):::literal f0[["bound(?item)"]] f0 --> v1 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c2 --"mwapi:api"--> c4 c2 --"mwapi:endpoint"--> c6 c2 --"mwapi:gcmtitle"--> c8 c2 --"mwapi:generator"--> c10 c2 --"mwapi:gcmtype"--> c12 c2 --"mwapi:gcmlimit"--> c14 c2 --"mwapi:gcmsort"--> c16 c2 --"mwapi:gcmdir"--> c18 v2 --"mwapi:apiOutput"--> c20 end bind1[/"substring(?file,'6^^xsd:integer')"/] v2 --o bind1 bind1 --as--o v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P18".-> v3 end