Ultipa filter judges whether a metadata meets the requirement by applying an expression against its property or schema. Features of Ultipa filter are:
- It is an expression encapsulated in curly braces
{ }
, and yields a value of bool or null - It usually (but not necessarily) calls the schema and/or property of current metadata
- It validates a metadata only if the expression returns true
When the expression yields neither bool nor null, convert the result to bool based on below principles:
Type | Convert to true | Convert to false |
---|---|---|
int32,uint32,int64,uint64,float,double | When it is NOT 0 | When it is 0 |
string,text | When the first character is When the first character is NOT '0' | When the first character is '0' |
datetime | When it is NOT '0000-00-00 00:00:00' | When it is '0000-00-00 00:00:00' |
timestamp | When it is NOT '1970-01-01 08:00:00 +08:00' (or equivalent) | When it is '1970-01-01 08:00:00 +08:00' (or equivalent) |
point | Never | Any value |
list | Never | Any value |
Scenario A: General Filtering
In any query command, filter current metadata by calling constant and/or alias defined in previous statement. For example:
find().edges({time >= "2021-09-01 09:00:00"})
...
... as maxAge
find().nodes({age == maxAge})
...
The properties filtered in this scenario, e.g. the edge property time and node property age in the above code, can be directly used for queries without any acceleration processing.
Scenario B: Inter-Step Filtering
In template query, filter current metadata by calling prev_n
、prev_e
and/or alias defined earlier in currernt statement. For example:
n(as start).e()[3].n({level == start.level})
...
n().e({@transfer.time > prev_e.time})[3].n()
...
The properties filtered in this scenario, e.g. the node property level and edge property time in the above code, must be LTE-ed before being used for queries.
Parameters
path_ascend()
andpath_descend()
used in some path query commands serve a inter-step comparison purpose similar to the inter-step filtering of template query. They also require the subject property to be LTE-ed, just that the subject property is not used in the form of filter.
Scenario C: Full-Text Filtering
In any query command, filter the full-text index of current metadata using a key-word constant. For example:
find().nodes({~content CONTAINS "graph computing parallel"})
...
The full-text index filtered in this scenario, e.g. the content in the above code, must be created using command create().node_fulltext()
before being used for queries.