Dgraph DQL Tour


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 outgoing string edge edge_name where the string contains all listed terms.

  • anyOfTerms(edge_name, "term1 ... termN"): As with allOfTerms, but matches at least one term.

  • The equalities and inequalities can be applied to edges of types: int, float, string and date

    • eq(edge_name, value): equal to
    • ge(edge_name, value): greater than or equal to
    • le(edge_name, value): less than or equal to
    • gt(edge_name, value): greater than
    • lt(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.

2.6 Functions and filtering