Skip to content

DQL Query Language

DQL (Dgraph Query Language) is the primary query language for OWLGraph. It supports graph traversals, filtering, aggregation, and OWLGraph’s ontology-aware extensions.

{
q(func: type(Animal)) {
name
dgraph.type
}
}
FunctionDescription
type(X)Nodes with type X (subsumption-aware)
exactType(X)Nodes with explicitly asserted type X
eq(pred, val)Equality match
has(pred)Nodes with the predicate
allofterms(pred, "words")Full-text term match
anyofterms(pred, "words")Any term match
regexp(pred, /pattern/)Regex match
uid(0x1, 0x2)Specific UIDs
{
q(func: type(Book)) @filter(eq(testament, "Old") AND has(reference)) {
name
reference
}
}

Operators: AND, OR, NOT, eq, ge, le, gt, lt, has, type

{
q(func: type(Person), first: 10, offset: 20, orderasc: name) {
name
}
}
{
q(func: type(Prophecy)) {
count(uid)
min(val(publicationYear))
max(val(publicationYear))
}
}
{
q(func: type(Prophecy)) {
reference
text
hasTheme { name }
fulfilledBy {
reference
inBook { name testament }
}
}
}

Follow a transitive property:

# Unbounded: follow until no more edges
{
q(func: eq(name, "San Francisco")) {
name
locatedIn* { name }
}
}
# Bounded: maximum N hops
{
q(func: eq(name, "San Francisco")) {
name
locatedIn*2 { name }
}
}
{
q(func: type(Dog)) {
name
dgraph.type @facets(owl.inferred)
}
}
{
var(func: type(Author)) {
books as authorOf {
themes as hasTheme
}
}
q(func: uid(themes), orderdesc: val(count)) {
name
appearances: val(count)
}
}
{
set {
_:new <dgraph.type> "Dog" .
_:new <name> "Rex" .
}
}

For full DQL syntax, see the Dgraph DQL documentation.