Common queries for the Knowledge Graph.
1
2
3
4
5
PREFIX sea: <http://sea-forge.com/schema/core#>
PREFIX sea-debt: <http://sea-forge.com/schema/debt#>
PREFIX sea-inc: <http://sea-forge.com/schema/incident#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
1
2
3
4
5
6
7
SELECT ?entity ?name ?domain
WHERE {
?entity a sea:Entity ;
rdfs:label ?name ;
sea:inContext ?domain .
}
ORDER BY ?domain ?name
1
2
3
4
5
6
SELECT ?entity ?domain
WHERE {
?entity a sea:Entity ;
rdfs:label "Warehouse.A" ;
sea:inContext ?domain .
}
1
2
3
4
5
6
7
8
9
10
SELECT ?flow ?from_name ?to_name ?resource ?quantity
WHERE {
?flow a sea:Flow ;
sea:from ?from ;
sea:to ?to ;
sea:resource ?resource ;
sea:quantity ?quantity .
?from rdfs:label ?from_name .
?to rdfs:label ?to_name .
}
1
2
3
4
5
6
7
8
SELECT ?flow ?from_name ?quantity
WHERE {
?flow a sea:Flow ;
sea:from ?from ;
sea:to <http://sea-forge.com/entity/warehouse-a> ;
sea:quantity ?quantity .
?from rdfs:label ?from_name .
}
1
2
3
4
5
6
7
8
9
SELECT ?to_name (SUM(?quantity) as ?total)
WHERE {
?flow a sea:Flow ;
sea:to ?to ;
sea:quantity ?quantity .
?to rdfs:label ?to_name .
}
GROUP BY ?to_name
ORDER BY DESC(?total)
1
2
3
4
5
6
7
8
SELECT ?entity ?name (COUNT(?flow) as ?connections)
WHERE {
?entity a sea:Entity ;
rdfs:label ?name .
{ ?flow sea:from ?entity } UNION { ?flow sea:to ?entity }
}
GROUP BY ?entity ?name
ORDER BY DESC(?connections)
1
2
3
4
5
6
7
8
SELECT ?debt ?label ?status ?concept
WHERE {
?debt a sea-debt:SemanticDebtItem ;
rdfs:label ?label ;
sea-debt:status ?status ;
sea-debt:regardingConcept ?concept .
FILTER (?status IN ("Blocking", "Open"))
}
1
2
3
4
5
6
7
8
SELECT ?debt ?label ?concept
WHERE {
?debt a sea-debt:SemanticDebtItem ;
sea-debt:status "Blocking" ;
rdfs:label ?label ;
sea-debt:regardingConcept ?concept .
?concept sea:inContext <http://sea-forge.com/context/finance> .
}
1
2
3
4
5
6
7
8
9
SELECT ?policy (COUNT(?debt) AS ?debtCount)
WHERE {
?debt a sea-debt:SemanticDebtItem ;
sea-debt:regardingConcept ?policy .
?policy a sea:Policy .
}
GROUP BY ?policy
ORDER BY DESC(?debtCount)
LIMIT 10
1
2
3
4
SELECT ?p ?o
WHERE {
<http://sea-forge.com/entity/warehouse-a> ?p ?o .
}
1
2
3
4
SELECT ?s ?p
WHERE {
?s ?p <http://sea-forge.com/entity/warehouse-a> .
}
1
2
3
curl -X POST http://localhost:7878/query \
-H "Content-Type: application/sparql-query" \
-d "SELECT * WHERE { ?s ?p ?o } LIMIT 10"
1
2
3
4
5
6
curl -X POST http://localhost:8000/graph/query \
-H "Content-Type: application/json" \
-d '{
"language": "sparql",
"query": "SELECT * WHERE { ?s ?p ?o } LIMIT 10"
}'