DS Catalog:SPARQL Query Service/example queries: Difference between revisions

Line 116: Line 116:
This query generates a list of string values of a particular type of ''as recorded'' data occurring in a DS Record which have not be qualified by an authority value (i.e., reconciled to its linked data equivalent in a Linked Open Vocabulary or Authority).
This query generates a list of string values of a particular type of ''as recorded'' data occurring in a DS Record which have not be qualified by an authority value (i.e., reconciled to its linked data equivalent in a Linked Open Vocabulary or Authority).
<syntaxhighlight lang="SPARQL">
<syntaxhighlight lang="SPARQL">
SELECT ?record ?recordLabel ?string ?authority ?authorityLabel #?roleLabel # (un-comment roleLabel variable when querying name data to get role information)
SELECT ?record ?recordLabel ?string ?authority ?authorityLabel ?roleLabel
# declared variables give a link to a record, the label of the record, a link to the authority record, and a label for the the authority record
 
WHERE {
WHERE {
   ?record p:P14 ?stringStatement .
   ?record p:P14 ?stringStatement .
# identifies records with statements with corresponding property (change P-value for as recorded value to be queried)
   ?stringStatement ps:P14 ?string .
   ?stringStatement ps:P14 ?string .
# identifies statements that have strings with corresponding property (change P-value for as recorded value to be queried)
   #FILTER NOT EXISTS { ?stringStatement pq:P17 ?authority . }
   #FILTER NOT EXISTS { ?stringStatement pq:P17 ?authority . }
# identifies those statements which have not been enriched with authority values (change P-value for authority file value to be queried)
   OPTIONAL { ?stringStatement pq:P15 ?role . }
   OPTIONAL { ?stringStatement pq:P15 ?role . }
# only used for name data, un-comment optional clause when querying name data
    
    
     SERVICE wikibase:label {
     SERVICE wikibase:label {
Line 134: Line 128:
}
}
ORDER BY ASC (?string)
ORDER BY ASC (?string)
# this sorts the results alphabetically by string values
<syntaxhighlight>
<syntaxhighlight>
Bots, Bureaucrats, emailconfirmed, Administrators
30,567

edits