Find files that use a particular SDC field
Using Special:MediaSearch
You can do structured data queries using Special:MediaSearch. Here are a couple of examples:
-
To find uses of a particular statement:
- Videos with property P1651 (YouTube video ID): https://commons.wikimedia.org/wiki/Special:MediaSearch?type=video&search=haswbstatement%3AP1651
- Images with property P12120 (Flickr photo ID): https://commons.wikimedia.org/wiki/Special:MediaSearch?type=image&search=haswbstatement%3AP12120
-
To find a statement with a particular value:
- Images with P7482=Q66458942 (source of file is original creation by uploader): https://commons.wikimedia.org/wiki/Special:MediaSearch?search=haswbstatement%3AP7482%3DQ66458942&type=image
Using the Commons Query Service
You can run SPARQL queries with the Commons Query Service. I’m not super experienced with SPARQL, but I’ll use this as a place to gather queries I’ve been able to get working.
-
This is a query that finds files which have a P7482=Q74228490, P137=Q420747, and one of two Flickr URLs in the P973 field.
SELECT ?item ?described_url WHERE { ?item wdt:P7482 wd:Q74228490 . # P7482 (source of file) = Q74228490 (file available on the internet) ?item p:P7482 ?statement . ?statement pq:P137 wd:Q103204. # P137 (operator) = Q420747 (National Library of Finland) ?statement pq:P973 ?described_url. VALUES (?described_url) { (<https://www.flickr.com/photos/sunrise/29916169/>) (<https://www.flickr.com/photos/sunrise/29916169>) } } LIMIT 1
Link to query in WCQS, which returns a single result.
-
This is a query that finds users with a particular value in the Flickr User ID field:
SELECT ?image WHERE { # P170 (creator) / P3267 (Flickr user ID) = specified ID ?file p:P170 ?creator . ?creator pq:P3267 "52498302@N08" . # Retrieve the image URL to display as a link ?file schema:url ?image . }