Dgraph Tour
basic
Functions and filtering
Nodes are filtered based on functions applied to the node’s outgoing edges.
So far the queries have only applied a filter to the top level nodes, but filters can be applied to any node in the query.
Note the syntax difference between filtering at the root of a query and filtering on internal blocks.
There are many functions for filtering, some of them are
allOfTerms(edge_name, "term1 ... termN")
: matches nodes with an outgoingstring
edgeedge_name
where the string contains all listed terms.anyOfTerms(edge_name, "term1 ... termN")
: As withallOfTerms
, but matches at least one term.The equalities and inequalities can be applied to edges of types:
int
,float
,string
anddate
eq(edge_name, value)
: equal toge(edge_name, value)
: greater than or equal tole(edge_name, value)
: less than or equal togt(edge_name, value)
: greater thanlt(edge_name, value)
: less than
There’s also regular expressions, full text search and geo search, but those are bigger topics that’ll have their own section in the tutorial
Functions can only be applied to predicates that have been indexed except
the case when comparison functions (eq
, ge
, gt
, le
, lt
) are used in filter -
that’s part of the lesson about schema.