Simple Example
Below are a collection of simpler queries.
All examples use the following context details
CONTEXT= {
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
}
Search by type and location with exact match
{ "@context": $CONTEXT
"sq:query":[
{
"@type":"schema:LocalBusiness",
"schema:address": {
"schema:addressLocality": "Vienna"
}
}
]
}
Search by type and location with contains in, ignore case match
{ "@context": $CONTEXT
"sq:query":[
{
"@type":"schema:LocalBusiness",
"schema:address": {
"schema:addressLocality": {
"sq:value": "Vienna",
"sq:op":"iContains"
}
}
}
]
}
Search for objects belonging to the POI DS with nearby
{ "@context": $CONTEXT
"sq:query":[
{
"ds:compliesWith": {
"sq:value":"https://semantify.it/ds/sloejGAwT",
"sq:datatype":"iri"
},
"schema:geo": {
"sq:nearby":{
"sq:latitude":"$LAT",
"sq:longitude":"$LONG",
"sq:distance":"$DIST"
}
}
}
]
}
Search by type and domain specification filter
Here is a search for objects belonging to the DZT POI domain specification , with an additional filter for a specific type.
{ "@context": $CONTEXT
"sq:query":[
{
"ds:compliesWith": {
"sq:value":"https://semantify.it/ds/sloejGAwT",
"sq:datatype":"iri"
},
"@type":"schema:Museeum",
}
]
}
Search for objects belonging to one of several types and domain specification filter
{ "@context": $CONTEXT
"sq:query":[
{
"ds:compliesWith": {
"sq:value":"https://semantify.it/ds/sloejGAwT",
"sq:datatype":"iri"
},
"@type": ["schema:Museeum", "schema:ParkingFacility"],
}
]
}
Search for objects given a text string in different properties
If you want to search for object which contain a certain string in one more properties then you can define a query such as the following: Here we search for object that contain the string Vienna in either the name or description of the object.
{ "@context": $CONTEXT
"sq:query":[
{
"sq:or":[
{
"schema:name": {
"sq:value": "Vienna",
"sq:op":"iContains"
}
},
{
"schema:description": {
"sq:value": "Vienna",
"sq:op":"iContains"
}
}
]
}
]
}
Search for objects which are in a given radius to a defined lat /long pair
Another use case is to find objects which are in a certain radius/geo-proximity to a point. To do so, we can run the following shape query which searches for objects where their schema:geo property (with a schema:GeoCoordindate) has a certain straight line distance to a defined lat/long pair.
{ "@context": $CONTEXT
"sq:query":[
{
"schema:geo": {
"sq:nearby":{
"sq:latitude":"LAT_VALUE",
"sq:longitude":"LONG_VALUE",
"sq:distance":"DIST_IN_KM"
}
}
}
]
}
Example API call
curl --location 'https://proxy.opendatagermany.io/api/ts/v1/kg/things' \
--header 'Content-Type: application/ld+json' \
--header 'x-api-key: $API_KEY' \
--data-raw '{ "@context":{
"ds": "https://vocab.sti2.at/ds/",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"schema": "https://schema.org/",
"sh": "http://www.w3.org/ns/shacl#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"odta": "https://odta.io/voc/",
"sq": "http://www.onlim.com/shapequery/",
"@vocab": "http://www.onlim.com/shapequery/"
},
"sq:query":[
{
"@type":"schema:LocalBusiness",
"schema:address": {
"schema:addressLocality": "Vienna"
}
}
]
}'
Updated 5 months ago