UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Graphset
    • Schema
    • Property
    • Constraints
    • Insert
    • Overwrite or Insert
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • All Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Table Functions
    • Null Functions
    • Type Conversion Functions
  • Operators
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
    • Cache
    • Overview
    • Managing HDC Graphs
    • HDC Graph Queries
    • Process
    • Job
    • Execution Plan
    • Alias
    • Filter
    • Values and Types
    • Data Flow in Queries
    • Comments
    • Reserved Words
  • Access Control
  1. Docs
  2. /
  3. UQL
  4. /
  5. Syntax

Filter

Overview

A filter sets conditions for retrieving nodes and edges based on schemas and properties and is used within certain clause methods.

In UQL, filters are enclosed in curly braces {}. Filter expressions typically contain comparison operators such as =, >, <, and logical operators such as AND and OR. Each filter expression evaluates to a boolean (TRUE or FALSE) or null, validating nodes or edges only it returns TRUE.

General Filter

In this example, the filter {@user || @movie.rating > 3} specifies that the clause retrieves @user nodes or @movie nodes with a rating greater than 3:

UQL
find().nodes({@user || @movie.rating > 3}) as n
return n{*}

Simplified Filter

In this example, the filter {age} specifies that the clause retrieves nodes with an age property whose value, when subtracted by 30, is non-zero:

UQL
find().nodes({age - 30}) as n
return n{*}

The table below summarizes how different data types are evaluated as TRUE or FALSE in filters:

Type
TRUEFALSE
int32,uint32,int64,uint64,float,doubleNon-Zero0
string,textDoes not start with the character "0"Starts with the character "0"
datetimeAny date except 0000-00-00 00:00:000000-00-00 00:00:00
timestampAny date except 1970-01-01 08:00:00 +08:00 or equivalent1970-01-01 08:00:00 +08:00 or equivalent
pointNeverAny value
listNeverAny value

Inter-Step Filter

In a path template, you can use the system alias prev_n or prev_e to facilitate inter-step filtering.

This query finds 4-step outgoing transaction paths between @card nodes, ensuring that each transaction time is greater than the previous one:

UQL
n({@card}).re({@transfers}).n({@card})
  .re({@transfers.time > prev_e.time})[3]
  .n({@card}) as p
return p{*}

Any property called by prev_n or prev_e, such as the time property in the example, must be LTE-ed for acceleration.