Search for Text Across All Content — Confluence Cloud Macro
The macro sets parameters for the search term, result limit, and sorting order. It constructs a CQL query to find relevant content and executes it against the Confluence API. The results are displayed as a list.
User Parameters
Search Term
Enter a search term
Template
#set($searchTerm = $parameters.searchTerm)
#set($limit = 50)
#set($sortOrder = "created desc")
## Define CQL query
#set($cqlQuery = "type in (page, blogpost, attachment) AND text ~ '\'$searchTerm\'' order by $sortOrder")
## Execute the query with expanded version data
#set($response = $ConfluenceManager.get("/wiki/rest/api/content/search?cql=$cqlQuery&limit=$limit&expand=space,version"))
<ul>
<p style="margin-bottom: 10px;">
Search results for <strong>$searchTerm:</strong>
</p>
#if($response.results.size() > 0)
#foreach($content in $response.results)
<li style="list-style-type: top; margin-left: 30px;">
<span class="aui-lozenge aui-lozenge-subtle aui-lozenge-success">$content.type</span>
<a href="${response._links.base}$content._links.webui" target="_blank">$content.title</a>
in $content.space.name space
</li>
#end
#else
<li>No results found for "$searchTerm"</li>
#end
</ul>Recommended Macros
User macro for displaying issues using custom JQL filter
Content that is shown only if a user is in a particular group
Macro for generating ID in base32 format
Create dropdown menus in Confluence Cloud with custom sets of options, multiselect features, and permission gates
Generate a list of all the content created by a current user by default or a specified user across your Confluence site.
Find image within page attachments. Handy for reuse files and update them all at once
Add a configurable tile to a Confluence page
Display and interact with an OpenAPI / Swagger specification directly in Confluence by rendering a fully featured Swagger UI from a provided JSON URL