The instructions on this page describe how to use functions in CQL to define structured search queries to search for content in Confluence.
A function in CQL appears as a word followed by parentheses which may contain one or more explicit values. In a clause, a function is preceded by an operator, which in turn is preceded by a field. A function performs a calculation on either specific Confluence data or the function's content in parentheses, such that only true results are retrieved by the function and then again by the clause in which the function is used.
This document also covers the reserved characters and words that Confluence uses.
Perform searches based on the currently logged-in user.
Note that this function can only be used by logged-in users. Anonymous users cannot use this function.
1 2currentUser()
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | no | no | no | no | no | no |
Find content that was created by me
1 2creator = currentUser()
Find content that mentions me but wasn't created by me
1 2mention = currentUser() and creator != currentUser()
Perform searches based on the end of the current day. See also endOfWeek(), endOfMonth, endOfYear(), startOfDay(), startOfWeek(), startOfMonth() and startOfYear().
1 2endOfDay()
or
1 2endOfDay("inc")
where inc
is an optional increment of (+/-)nn(y|M|w|d|h|m)
(+/-)
sign is omitted, plus is assumed.= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content created since the end of yesterday
1 2created > endOfDay("-1d")
Perform searches based on the end of the current month. See also endOfDay, endOfWeek and endOfYear; and startOfDay, startOfWeek, startOfMonth, and startOfYear.
1 2endOfMonth()
or
1 2endOfMonth("inc")
where inc
is an optional increment of (+/-)nn(y|M|w|d|h|m)
(+/-)
sign is omitted, plus is assumed.= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content modified before the end of the month
1 2lastmodified < endOfMonth()
Perform searches based on the end of the current week. See also endOfDay, endOfMonth and endOfYear; and startOfDay, startOfWeek, startOfMonth, and startOfYear.
1 2endOfWeek()
or
1 2endOfWeek("inc")
where inc
is an optional increment of (+/-)nn(y|M|w|d|h|m)
(+/-)
sign is omitted, plus is assumed.= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content created after the end of last week
1 2created > endOfWeek("-1w")
Perform searches based on the end of the current year. See also startOfDay, startOfWeek and startOfMonth; and endOfDay, endOfWeek, endOfMonth and endOfYear.
1 2endOfYear()
or
1 2endOfYear("inc")
where inc
is an optional increment of (+/-)nn(y|M|w|d|h|m)
(+/-)
sign is omitted, plus is assumed.= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content created by the end of this year:
1 2created < endOfYear()
Perform searches based on the start of the current day. See also endOfWeek, endOfMonth and endOfYear; and startOfDay, startOfWeek, startOfMonth, and startOfYear.
1 2startOfDay()
or
1 2startOfDay("inc")
where inc
is an optional increment of (+/-)nn(y|M|w|d|h|m)
(+/-)
sign is omitted, plus is assumed.= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content created since the start of today
1 2created > startOfDay()
Find content created in the last 7 days
1 2created > startOfDay("-7d")
Perform searches based on the start of the current month. See also endOfDay, endOfWeek and endOfYear; and startOfDay, startOfWeek, startOfMonth, and startOfYear.
1 2startOfMonth()
or
1 2startOfMonth("inc")
where inc
is an optional increment of (+/-)nn(y|M|w|d|h|m)
(+/-)
sign is omitted, plus is assumed.= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content created since the start of the month
1 2created >= startOfMonth()
Perform searches based on the start of the current week. See also endOfDay, endOfMonth, and endOfYear; and startOfDay, startOfWeek, startOfMonth, and startOfYear.
1 2startOfWeek()
or
1 2startOfWeek("inc")
where inc
is an optional increment of (+/-)nn(y|M|w|d|h|m)
(+/-)
sign is omitted, plus is assumed.= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content created since the start of the week
1 2created >= startOfWeek()
Perform searches based on the start of the current year. See also startOfDay, startOfWeek, and startOfMonth; and endOfDay, endOfWeek, endOfMonth, and endOfYear.
1 2startOfYear()
or
1 2startOfYear("inc")
where inc
is an optional increment of (+/-)nn(y|M|w|d|h|m)
(+/-)
sign is omitted, plus is assumed.= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
yes | yes | no | no | yes | yes | yes | yes | no | no |
Find content created this year
1 2created >= startOfYear()
Returns a list of space keys, corresponding to the favorite spaces of the logged-in user.
1 2favouriteSpaces()
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
no | no | no | no | no | no | no | no | yes | yes |
1 2space IN favouriteSpaces()
1 2space IN (favouriteSpaces(), 'FS', 'TS')
5.9
Returns a list of IDs of recently viewed content for the logged-in user. This function can only return a maximum of 200 results.
1 2recentlyViewedContent(limit, offset)
The total of both parameters (limit
or offset
) must not exceed 200.
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
no | no | no | no | no | no | no | no | yes | yes |
1 2id in recentlyViewedContent(10)
1 2id in recentlyViewedContent(10, 20)
5.9
Returns a list of key of spaces recently viewed by the logged-in user. This function can only return a maximum of 200 results.
1 2recentlyViewedSpaces(limit)
The limit
parameter must not exceed 200.
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
no | no | no | no | no | no | no | no | yes | yes |
1 2space in recentlyViewedSpaces(10)
5.9
CQL has a list of reserved characters :
" "
)"-"
"~"
"+"
"."
","
";"
"?"
"|"
"*"
"/"
"%"
"^"
"$"
"#"
"@"
"["
"]"
If you wish to use these characters in queries, you need to:
'
) or double quote-marks ("
);
and, if you are searching a text field and the character is on the list of reserved characters for text searchesCQL has a list of reserved words. These words need to be surrounded by quotation marks if you wish to use them in queries:
"after", "and", "as", "avg", "before", "begin", "by","commit", "contains", "count", "distinct", "else", "empty", "end", "explain", "from", "having", "if", "in", "inner", "insert", "into", "is", "isnull", "left", "like", "limit", "max", "min", "not", "null", "or", "order", "outer", "right", "select", "sum", "then", "was", "where", "update"
Strings that start with numbers also need to be surrounded by quotation marks, for example, "123B"
.
Rate this page: