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.
Conversion between number and True/False in a filter:
- From number to True/False, non 0 is true, 0 is false
- From True/False to number, true is 1, false is 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.
Example: find 10 cards whose balances are NOT 0
find().nodes({@card.balance}) as n
limit 10
return n{*}
The implementation scenarios of Ultipa filter:
Implementation | Specification | Example |
---|---|---|
Common filtering | To filter current node or edge in any types of queries | {time > "2022-02-24 07:00:00"} |
Inter-step filtering | To filter current node or edge using precedent nodes or edges in the same path | {time > prev_e.time} |
Full-text filtering | To filter current node or edge against the word segmentation result of any of their properties ( refer to Conditional Operator - Contains and Index | Full-text | LTE - Full-text Filter) | {~content contains "graph ultra* database"} |
(The "time" is a property name, "content" is the full-text index for a property)