How to Filter¶
Abstract
This page tells you how to use query filter to get tasks you want.
Labtasker provides a versatile query filter mechanism to list / update / fetch tasks you want.
It supports:
- Query a specific field of nested dicts
- Query using logical operators and comparison operators (e.g.
>=
,<=
,in
,==
) - Query using regular expressions (e.g.
regex(task_name, "^[a-z]-\d$")
) - Query using time and date (e.g.
created_at >= date("3 hours ago")
)
Syntaxes¶
Originally, Labtasker filter comes with 2 syntaxes:
-
Python Native Syntax: Intuitive to use.
Note: Does not supportnot in
,not expr
, or!=
due to null value ambiguities -
MongoDB Syntax: More powerful but requires MongoDB knowledge.
Typical Use Cases¶
Filter by comparison¶
Why !=
, not in
, not
is not supported
Since database uses Three-Valued Logic, !=
, not
, not in
may result in null value ambiguity. Therefore we forbid such negation operations.
Filter by logical operators¶
Filter by date¶
Date string parsing is implemented using dateparser. You can refer to its documentation for supported syntaxes.
Note: if UTC is not specified, the time provided will be considered as local time and converted to UTC first before applying query.
For more detailed usage and tests, you can see the code here: https://github.com/luocfprime/labtasker/tree/main/tests/test_client/test_core/test_query_transpiler/test_matching.py