Embed a search

The CQL Search macro keeps one query on the page and renders a table for whoever opens it. The query runs again for each viewer.

Updated .

Insert the macro

  1. Edit the page.
  2. Type /CQL Search and insert the macro.
  3. In the configuration dialog, enter the query in CQL.
  4. Choose columns. The choices are Title, Type, Space, Modified, and Creator. If you clear every column, the table uses Title, Space, and Modified.
  5. Choose a page size of 10, 25, or 50. The default is 25.
  6. Choose Save, then publish the page.

Until a query is saved, the macro says “Add a CQL query from the macro configuration.”

Page tokens

These tokens work only in the macro, because only the macro knows which page it sits on. They are replaced outside of quotes, and the value is inserted as a CQL string.

TokenBecomes
currentSpace() and spaceKey()The key of the space that contains the page
currentContent() and pageId()The id of the page that contains the macro

A query that uses one of those tokens on the Apps page fails with “Missing context,” because that page has no space or content id to substitute. currentUser() is not rewritten by the app. Confluence resolves it.

Example

Pages in this space, newest change first:

space = currentSpace() AND type = page ORDER BY lastModified DESC

More examples are in Write a query and Use cases.

Readers

The table loads when the page loads. Title is a link. Next and Previous appear when Confluence has another page of matches. Download CSV saves the rows currently shown. A viewer with no matches sees “Nothing matched.” A query Confluence rejects shows “Search failed” and the message from the search.

An inactive license shows “Upgrade required” and does not run the search.