-
-
Notifications
You must be signed in to change notification settings - Fork 115
Filter Expressions for Advanced Search
This page describes an advanced search
feature which can be used in the sleek search bar. If the text you type in the search bar is not a well-formed filter expression, sleek will try to search for exactly what you typed as a literal string match.
The advanced search
functionality seamlessly integrates with the search filter feature, enabling a faster and more efficient use of the application.
Here are some examples of filter expressions that you can type. Go ahead and experiment on your own!
+bills and due: < tomorrow
pri=A and due: and +
(A) or due:2021-06
"some words in the todo" and +bugs
@home or (@work and priority < D and due: < today+3b)
@home and +bills
not complete and !+
due: < tomorrow
The +
begins a project name and the @
begins a context name, just as in a todo.txt task.
The "
string lets you specify a literal text match on the text of the todo. You can also use a single-quoted string, or even a JavaScript regular expression like /[a-zA-Z][0-9]+.*/
.
Don't be concerned if you see no matches while you are typing your filter expression. If the filter expression is not syntactically correct, there may be no matches until you complete the expression. Sleek will try to keep the last valid query if you continue to type. So for instance, if you type +bills and pr
that is not valid, but sleek will continue to show the result of the expression +bills
until you reach another valid query like +bills and pri > A
. (This could be a little confusing or surprising, and we are working on ideas to give you more feedback about the query as you type it.)
The remainder of this page goes through all of the features of the filter expression language in detail. You don't necessarily have to read any or all of this to use the filter expressions, but all of the details should be here if you need to know them.
A filter expression is a logical
expression whose value must ultimately be a boolean (true or false) to decide whether the expression matches or not. Sub-expressions can be combined with the three boolean operators or
, and
, and not
to build bigger expressions.
Each of these operators has three names so that you can use whichever ones seem most natural to you:
-
or
can also be specified asOR
or as||
. -
and
can also be specified asAND
or as&&
. -
not
can also be specified asNOT
or as!
.
Logical expressions can also be parenthesized to control the order of evaluation. OR has the weakest precedence, AND the next stronger precedence, and NOT the strongest precedence. Examples of logical expressions:
(+bills or +errands) and @home and not complete
due: <= today && !priority
The logical operators are used to combine lower-level values, each of which results from one of:
- project match
- context match
- due date comparison
- priority comparison
- literal text match
- regular expression match
Each of these will be described in more detail in the following sections.
- The symbol
+
introduces a project match. By itself, the+
matches any todo with a project. -
+bi
will match any todo with a project that contains the sub-stringbi
, eg: it will match projects+bills
and+ambitious
. -
+"big"
or+big"
specifies an exact match, so it will match the projectbig
but not any longer project name likebigtask
. - if your project name contains parentheses, you will need to match it exactly with the quote syntax, eg:
+"project(A)"
.
- The symbol
@
introduces a context match. By itself, the@
matches any todo with a context. -
@ho
will match any todo with a context that contains the sub-stringho
. -
@"home"
or@home"
specifies an exact match, so it will match the contexthome
but not any longer context name likehomeland
. - if your context name contains parentheses, you will need to match it exactly with the quote syntax, eg:
@"my(main)place"
.
- due dates can be tested using the keyword
due:
. By itself,due:
is true if the todo has a due date. -
due:
followed by a comparison operator (==
,=
,!=
,<
,<=
,>
, or>=
) and a DATE will test against specific dates. DATE can be an ISO date string (YYYY-MM-DD) or the keywordstoday
,tomorrow
, oryesterday
. Examples:due: <= 2021-08-14
,due: = today
. - You can also add or subtract an INTERVAL to/from a DATE. The intervals are the same ones used in the recurrence expressions: an integer followed by one of
dbwmy
. Example:due: > tomorrow-2w
. - a due date prefix match expression consists of
due:
immediately followed by the date string. The date string may be an ISO date or the first part of an ISO date. Examples:due:2021-06-28
will match a due date of exactly 2021-06-28, so that is the same effect asdue: == 2021-06-28
. However,due:2021
will match any due date in 2021, which is the same effect asdue: >= 2021-01-01 and due: <= 2021-12-31
.
-
t:
(threshold) dates can be tested using the keywordt:
. By itself,t:
is true if the todo has a threshold date. -
t:
followed by a comparison operator (==
,=
,!=
,<
,<=
,>
, or>=
) and a DATE will test against specific dates. DATE can be an ISO date string (YYYY-MM-DD) or the keywordstoday
,tomorrow
, oryesterday
. Examples:t: <= 2021-08-14
,t: = today
. - You can also add or subtract an INTERVAL to/from a DATE. The intervals are the same ones used in the recurrence expressions: an integer followed by one of
dbwmy
. Example:t: > tomorrow-2w
. - a threshold date prefix match expression consists of
t:
immediately followed by the date string. The date string may be an ISO date or the first part of an ISO date. Examples:t:2021-06-28
will match a threshold date of exactly 2021-06-28, so that is the same effect ast: == 2021-06-28
. However,t:2021
will match any threshold date in 2021, which is the same effect ast: >= 2021-01-01 and t: <= 2021-12-31
.
-
priority
will match any todo with a priority, and the expressionpriority <= B
will match any todo with priority A or B. You can also use the==
,=
,!=
,<
,>
, or>=
operators, and any letter fromA
toZ
to form a comparison. -
pri
can be used as an abbreviation forpriority
. - the alternate form
(B)
can be used as an equivalent topri == B
.
- if sleek can't parse your search string as a filter expression, it will default to doing a literal text match of your search against the string form of each todo.
- you can add a literal text match to a filter expression by surrounding it with quotes, either double quotes or single quotes. Examples:
"this text must be in the todo
",'single quotes'
,+bill and "some words"
.
- a regular expression is delimited by slashes, for example:
/[0-9]+/
will match any sequence of digits. It is matched against the string form of the todo using JavaScript regular expression syntax. For example,due: < today and / rec:+?[0-9]*[dbwmy]/
could be used to look for todos with a recurrence value that are due before today.