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 that in turn is preceded by a field. A function performs a calculation on either specific Confluence data or the function 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 list provides explanations and examples for the following functions:
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 | Yes | Yes |
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.
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.
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.
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.
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.
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.
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.
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.
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()
Perform searches based on current time.
1 2now()
or
1 2now("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 before current time.
1 2created <= now()
5.7
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 current space. Requires cqlcontext
with spaceKey
.
1 2currentSpace()
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
Yes | Yes | No | Yes | No | No | No | No | No | No |
1 2space = currentSpace()
1 2curl -u user:pwd 'http://localhost:8080/confluence/rest/api/search?cql=space%20=%20currentSpace()&cqlcontext=%7B"spaceKey":"TEST"%7D'
5.7
Returns a list of IDs of recently viewed content for the logged in user.
1 2recentlyViewedContent(limit, offset)
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
No | No | No | No | No | No | No | No | Yes | Yes |
Examples
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.
1 2recentlyViewedSpaces(limit)
= | != | ~ | !~ | > | >= | < | <= | IN | NOT IN |
---|---|---|---|---|---|---|---|---|---|
No | No | No | No | No | No | No | No | Yes | Yes |
Examples
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 ("
));CQL has a list of reserved words. These words need to be surrounded by quote-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"
Rate this page: