Project:Useful Queries
Revision as of 10:37, 7 December 2022 by DavidFichtmueller (talk | contribs)
Example Queries
Query Service: https://modelling.dissco.tech/query/
Select item that contains certain string
The following query uses these:
1SELECT ?item ?itemLabel
2WHERE {
3 ?item rdfs:label ?itemLabel.
4 FILTER(CONTAINS(LCASE(?itemLabel), "concept"@en)).
5}
List all authoritative items
All the items that have the property "in Concept Group": authoritative.
The following query uses these:
- Items: primary specimen data (Q22)
- Properties: in Concept Group (P4)
1SELECT ?item ?itemLabel WHERE { 2 ?item wdt:P4 wd:Q22. 3 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 4}
All items and sections from a Type
The following query uses these:
- Items: Digital Specimen (Q29), Section (Q28)
- Properties: subclass of (P14), instance of (P1), example (P18), has datatype (P10), minimum (P37), maximum (P38), Concept Namespace (P33), contains (P44), in Concept Group (P4), export order (P45), is mandatory (P9)
1SELECT ?section ?sectionLabel ?item ?itemLabel ?itemDescription ?example ?dataType ?min ?max ?mandatory ?namespace WHERE { 2 #the type to export is ODStype1802 3 BIND(wd:Q29 as $type). 4 5 { 6 #get all of the statements that are not sections 7 ?type wdt:P14?/p:P44 ?statement. 8 ?statement ps:P44 ?item. 9 OPTIONAL{ 10 ?statement pqv:P45/wikibase:quantityAmount ?order. 11 } 12 MINUS {?item wdt:P1 wd:Q28}. 13 }UNION{ 14 #get all of the sections 15 ?type p:P44 ?statement. 16 ?statement ps:P44 ?section. 17 ?statement pqv:P45/wikibase:quantityAmount ?order. 18 ?section wdt:P1 wd:Q28. 19 20 #get the items of the section 21 ?item p:P4 ?sectionStatement. 22 ?sectionStatement ps:P4 ?section. 23 OPTIONAL{ 24 ?sectionStatement pqv:P9/wikibase:quantityAmount ?mandatoryInternal. 25 26 } 27 } 28 #additional optional properties 29 OPTIONAL {?item wdt:P18 ?example} 30 OPTIONAL {?item wdt:P10 ?dataType} 31 OPTIONAL {?item wdt:P37 ?min} 32 OPTIONAL {?item wdt:P38 ?max} 33 OPTIONAL {?item wdt:P33 ?namespace} 34 BIND(IF(BOUND(?mandatoryInternal),?mandatoryInternal,"0") AS ?mandatory) 35 SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } 36 37 }ORDER BY ?order
List all the properties used by items within OpenDS
The following query uses these:
- Items: openDS (Q17)
- Properties: is part of (P8)
1SELECT ?property ?propertyLabel (COUNT (?item) as ?count) WHERE{ 2 ?item wdt:P8 wd:Q17; 3 ?prop ?statement. 4 ?property wikibase:directClaim ?prop. 5 FILTER (?property != wd:P8) 6 SERVICE wikibase:label { bd:serviceParam wikibase:language "en" .} 7 8} 9GROUP BY $property ?propertyLabel 10ORDER BY DESC(?count)
List all Type objects within OpenDS
The following query uses these:
- Items: Type (Q15), openDS (Q17)
- Properties: instance of (P1), is part of (P8), Concept Name (P26)
1SELECT ?type ?typeLabel ?conceptName WHERE { 2 ?type wdt:P1 wd:Q15. 3 ?type wdt:P8 wd:Q17. 4 ?type wdt:P26 ?conceptName . 5 SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 6}