Search Your Site for Pages Containing a Certain Macro - Server

This article is for Confluence Server (not Cloud)

You can use Confluence Query Language (CQL) and the Confluence REST API to search for pages containing a specific macro. See Advanced Searching using CQL and its section on searching for a macro.

See Confluence Server REST API and Confluence REST API examples if you have not used the REST API before. Also Pagination in the REST API.

Determine the name of the macro you want to search for by viewing the Storage Format markup for a page that contains an instance of the macro. The macro name appears in the markup as an “ac:name” attribute on an “ac:structured-macro” like this for the survey macro:

1 <ac:structured-macro ac:name="survey"...

 

You can invoke a search for all pages that contain a survey macro by using curl like this:

curl -u username:password http://myhost:8080/rest/api/content/search?cql=macro=survey

The results will be in JSON and will contain a results object that contains an array of page objects. It will also contain a _links object that you can use, along with the start, limit, and size properties to determine if you got all results at once or if you need to do another search using the “next” link in _links to get the next page (see Pagination in the REST API).

In some cases you can indirectly perform a CQL search by using certain search terms in the Confluence search tool on your site. For example, to find pages with “multiexcerpt-include” macros on them, use the search term

1 macro = multiexcerpt\-include