Expression
Expression is a syntactical arithmetic combination of Operator and Operand. Every expression has a value.
-
Operator: conditional operators, logical operators, numeric operators (see the next chapter for operators and their precedence)
-
Operand: constant, alias, function, current schema, current property
Operand | Examples | Example Expressions |
---|---|---|
Constant | 1,"abc", "2020-01-01 0:0:0" | 1+3*2 |
Alias | nodes,edges,paths | nodes.level,edges.amount < 2000 |
Function | now(),count(nodes),year("2022-04-12") | year(edges.time) > 2020 |
Current schema | this.@ | @ == "card",@product |
Current property | this._id,this.name | level != 2 |
(Nodes, edges, paths listed above are the aliases of Edge, Node, and Path; "this" from the aliases of current node and edge can be omitted in most cases)
- Value: NODE,EDGE,PATH,ATTR(number, time, string, True/False),ARRAY,TABLE
Filter
Ultipa filter is an expression encapsulated in curly bracket { }
, which acquires the property and schema of node/edge by calling the alias. The expression produces true
if the current node/edge meets the filtering rules. The filtering of node/edge is supported by all Ultipa query operations.
- The conversion between value of filter and True/False:
Before Conversion | Converted |
---|---|
Not 0 | True |
0 | False |
True | 1 |
False | 0 |
When converting string, datetime to True/False: it will be converted to False if first character is 0, otherwise True. When converting timestamp to Ture/False, for instance, "1970-01-01 08:00:00" should be False, otherwise True.
Implementation | Specification | Example |
---|---|---|
Common filtering | To filter current node or edge in any types of queries | {time > "2022-02-24 07:00:00"} |
In-step filtering | To filter current node, current edge, the previous node, and the previous edge with system alias prev_n and prev_e in template query |
{time > prev_e.time} |
Full-text filtering | To filter all the texts in properties of current node and edge in any tpes of queries by full-text index | {~content contains "graph ultra* database"} |
(The "time" is a property name, "content" is the full-text index for a property)