CQL Function Reference

The instructions on this page describe how to use functions in CQL to define structured search queries to search for content in Confluence.  

Functions Reference

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.

List of Functions

currentUser()

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.

Syntax
currentUser()
Supported Fields

Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(error)

(error)

(error)

(error)

(tick)

(tick)

Examples
  • Find content that was created by me

    creator = currentUser()
  • Find content that mentions me but wasn't created by me

    mention = currentUser() and creator != currentUser()

^top of functions | ^^top of topic

endOfDay()

Perform searches based on the end of the current day. See also endOfWeek, endOfMonth and endOfYear; and startOfDay, startOfWeek, startOfMonth and startOfYear.

Syntax
endOfDay()

or

endOfDay("inc")

where inc is an optional increment of (+/-)nn(y|M|w|d|h|m)
  • If the plus/minus (+/-) sign is omitted, plus is assumed.
  • nn: number; y: year, M: month; w: week; d: day; h: hour; m: minute.

Supported Fields

Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(error)

(error)

Examples
  • Find content created since the end of yesterday

    created > endOfDay("-1d")

^top of functions | ^^top of topic

endOfMonth()

Perform searches based on the end of the current month. See also endOfDay, endOfWeek and endOfYear; and startOfDay, startOfWeek, startOfMonth and startOfYear.

Syntax
endOfMonth()

or

endOfMonth("inc")

where inc is an optional increment of (+/-)nn(y|M|w|d|h|m)
  • If the plus/minus (+/-) sign is omitted, plus is assumed.
  • nn: number; y: year, M: month; w: week; d: day; h: hour; m: minute.

Supported Fields
Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(error)

(error)

Examples
  • Find content modified before the end of the month

    lastmodified < endOfMonth()

^top of functions | ^^top of topic

endOfWeek()

Perform searches based on the end of the current week. See also endOfDay, endOfMonth and endOfYear; and startOfDay, startOfWeek, startOfMonth and startOfYear.

Syntax
endOfWeek()

or

endOfWeek("inc")

where inc is an optional increment of (+/-)nn(y|M|w|d|h|m)
  • If the plus/minus (+/-) sign is omitted, plus is assumed.
  • nn: number; y: year, M: month; w: week; d: day; h: hour; m: minute.

Supported Fields
Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(error)

(error)

Examples
  • Find content created after the end of last week

    created > endOfWeek("-1w")

^top of functions | ^^top of topic

endOfYear()

Perform searches based on the end of the current year. See also startOfDay, startOfWeek and startOfMonth; and endOfDay, endOfWeek, endOfMonth and endOfYear.

endOfYear()

or

endOfYear("inc")

where inc is an optional increment of (+/-)nn(y|M|w|d|h|m)
  • If the plus/minus (+/-) sign is omitted, plus is assumed.
  • nn: number; y: year, M: month; w: week; d: day; h: hour; m: minute.

Supported Fields
Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(error)

(error)

Examples
  • Find content created by the end of this year:

    created < endOfYear()

^top of functions | ^^top of topic

startOfDay()

Perform searches based on the start of the current day. See also endOfWeek, endOfMonth and endOfYear; and startOfDay, startOfWeek, startOfMonth and startOfYear.

Syntax
startOfDay()

or

startOfDay("inc")

where inc is an optional increment of (+/-)nn(y|M|w|d|h|m)
  • If the plus/minus (+/-) sign is omitted, plus is assumed.
  • nn: number; y: year, M: month; w: week; d: day; h: hour; m: minute.

Supported Fields

Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(error)

(error)

Examples
  • Find content created since the start of today

    created > startOfDay()
  • Find content created in the last 7 days

    created > startOfDay("-7d")

^top of functions | ^^top of topic

endOfMonth()

Perform searches based on the start of the current month. See also endOfDay, endOfWeek and endOfYear; and startOfDay, startOfWeek, startOfMonth and startOfYear.

Syntax
startOfMonth()

or

startOfMonth("inc")

where inc is an optional increment of (+/-)nn(y|M|w|d|h|m)
  • If the plus/minus (+/-) sign is omitted, plus is assumed.
  • nn: number; y: year, M: month; w: week; d: day; h: hour; m: minute.

Supported Fields
Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(error)

(error)

Examples
  • Find content created since the start of the month

    created >= startOfMonth()

^top of functions | ^^top of topic

startOfWeek()

Perform searches based on the start of the current week. See also endOfDay, endOfMonth and endOfYear; and startOfDay, startOfWeek, startOfMonth and startOfYear.

Syntax
startOfWeek()

or

startOfWeek("inc")

where inc is an optional increment of (+/-)nn(y|M|w|d|h|m)
  • If the plus/minus (+/-) sign is omitted, plus is assumed.
  • nn: number; y: year, M: month; w: week; d: day; h: hour; m: minute.

Supported Fields
Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(error)

(error)

Examples
  • Find content created since the start of the week

    created >= startOfWeek()

^top of functions | ^^top of topic

startOfYear()

Perform searches based on the start of the current year. See also startOfDay, startOfWeek and startOfMonth; and endOfDay, endOfWeek, endOfMonth and endOfYear.

startOfYear()

or

startOfYear("inc")

where inc is an optional increment of (+/-)nn(y|M|w|d|h|m)
  • If the plus/minus (+/-) sign is omitted, plus is assumed.
  • nn: number; y: year, M: month; w: week; d: day; h: hour; m: minute.

Supported Fields
Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(tick)

(tick)

(error)

(error)

(tick)

(tick)

(tick)

(tick)

(error)

(error)

Examples
  • Find content created this year

    created >= startOfYear()

favouriteSpaces()

Returns a list of space keys, corresponding to the favourite spaces of the logged in user. 

Syntax
favouriteSpaces()
Supported Fields
Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(tick)

(tick)

Examples
  • Find content which exists in the favourite spaces of the logged in user 

space IN favouriteSpaces()
  • Find content which exists in the favourite spaces of the logged in user as well as other listed spaces
space IN (favouriteSpaces(), 'FS', 'TS')
Available from version

5.9

^top of functions | ^^top of topic

recentlyViewedContent()

Returns a list of IDs of recently viewed content for the logged in user.

Syntax
recentlyViewedContent(limit, offset)
Supported Fields
  • ancestor
  • content
  • id
  • parent

Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(tick)

(tick)

Examples

  • Find contents with limit to recent 10 history
id in recentlyViewedContent(10)
  • Find contents with limit to recent 10 history, but skip first 20
id in recentlyViewedContent(10, 20)
Available from version

5.9

^top of functions | ^^top of topic

recentlyViewedSpaces()

Returns a list of key of spaces recently viewed by the logged in user.

Syntax
recentlyViewedSpaces(limit)
Supported Fields
  • space

Supported Operators

=

!=

~

!~

>

>=

<

<=

IN

NOT IN

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(error)

(tick)

(tick)

Examples

  • Find spaces with limit to recent 10 history
 space in recentlyViewedSpaces(10)
Available from version

5.9

^top of functions | ^^top of topic

 

 

Reserved Characters

CQL has a list of reserved characters :

  • space (" ")
  • "+"
  • "."
  • ","
  • ";"
  • "?"
  • "|"
  • "*"
  • "/"
  • "%"
  • "^"
  • "$"
  • "#"
  • "@"
  • "["
  • "]"

 

If you wish to use these characters in queries, you need to:

  • surround them with quote-marks (you can use either single quote-marks (') or double quote-marks ("));
    and, if you are searching a text field and the character is on the list of reserved characters for Text Searches,
  • precede them with two backslashes.

Reserved Words

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"

 

 

Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport