Write a query
CQL Search sends one query to Confluence search. The language is Confluence Query Language, the same syntax documented by Atlassian for advanced search.
Updated . Atlassian’s reference: Advanced searching using CQL.
Content type
Most useful queries say what they are looking at, then narrow it.
type = page AND title ~ "runbook" type can be page, blogpost, attachment, comment, or another content type Confluence indexes. ~ is a text match. = is exact.
Examples
This space
space = currentSpace() AND type = page ORDER BY title ASC Use this in the macro. currentSpace() becomes the space key of the page you are editing.
Quiet pages
type = page AND lastModified < now("-180d") ORDER BY lastModified ASC now("-180d") stays relative, so the list is still right next month. Add AND space = currentSpace() in a macro when the list should stay in one space.
Contributions
type = page AND contributor = currentUser() ORDER BY lastModified DESC The app does not replace currentUser(). Confluence does, as the person who opened the page. On a shared page, each reader’s table is their own.
Child pages
parent = currentContent() AND type = page ORDER BY title ASC ancestor = currentContent() includes grandchildren as well. Both belong in the macro.
Labeled files
type = attachment AND label = "handbook" ORDER BY lastModified DESC App rules
- One query per search. There is no second filter box.
spaceKey(),currentSpace(),pageId(), andcurrentContent()are replaced only outside quotes. Inside"double quotes"or'single quotes'they stay as text.- If the macro cannot fill a token because the page context is missing, the search does not run. The message is
Missing context for currentSpace(), or whichever token was empty. - The Apps page has no page context. Write space keys and content ids out in full there, or use functions Confluence already understands, such as
currentUser().
Failed queries
The table shows “Search failed” and the message Confluence returned. Check the field name, the quotes, and that ORDER BY uses a field Confluence can sort. A query can also return “Nothing matched,” which means the syntax was fine and the viewer can see zero rows.