Skip to content

SPARQL queries

hughlilly edited this page Feb 27, 2020 · 2 revisions

Sample Queries for the Auckland Museum SPARQL endpoint at https://api.aucklandmuseum.com/sparql. Takes either 'application/sparql-results+json' or 'application/sparql-results+xml' 'Accept' headers.

Copyright statements

PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX ecrm: <http://erlangen-crm.org/current/>

SELECT ?statement (COUNT(?record) AS ?count) WHERE { 
  
  #Just Documentary Heritage
  #?record rdf:type ecrm:E84_Information_Carrier.
  	
  #Just Natural Sciences
  #?record rdf:type ecrm:E20_Biological_Object.
  
  #Just Human History
  #?record rdf:type ecrm:E22_Man-Made_Object.
  
  ?record ecrm:P138_has_representation/ecrm:P75_possesses/rdf:value ?statement.
  }

GROUP BY (?statement)
ORDER BY DESC (?count)

WWII ranks

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX am:  <http://collections.aucklandmuseum.com/ontology/core/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?rank (COUNT (?person) AS ?count) WHERE {
  ?person am:war/rdf:value "World War II, 1939-1945"^^xsd:string .
  ?person am:embarkation/am:rankOnEmbarkation ?rank
}

GROUP BY (?rank)
ORDER BY DESC (?count)

Tonnage, horses, men, and officers aboard WW1 transport ships

PREFIX am:<http://collections.aucklandmuseum.com/ontology/core/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT * WHERE {
  ?embarkation rdf:type am:Event.
  ?embarkation am:transportShip/rdf:value ?ship.
  ?embarkation am:grossTonnage ?tonnage.
  ?embarkation am:numberOfHorses ?horses.
  optional {?embarkation am:numberOfMen ?men;}
  optional {?embarkation am:numberOfOfficers ?officers;}
}
Clone this wiki locally