Is there any way we could search for empty pages in Confluence? I don't want to create a User Macro to achive this. Is there any way of this being done using the search?
The Search Field page advises that you can search for body content.
search.png
Unfortunately, Confluence uses Lucene in the background for its search, which is not very good at finding empty fields (especially for tokenized fields, like contentBody. I know you said you didn't care for a user macro, but I figured I'd include one anyway. You can use it to search for text in a page (we used it to find link content), and I updated it so that if you search for "blankpage" (without the quotes) then it will find all blank pages. In addition, an icon is displayed next to the page title if the page has children, so that you can see the blank pages that are used as a "folder" and which ones are really orphaned pages.
## @noparams #set ( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') ) #set ( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) ) #set ( $containerManager=$getInstanceMethod.invoke(null,null) ) #set ( $containerContext=$containerManager.containerContext ) #set ( $webResourceManager = $containerContext.getComponent('webResourceManager') ) $webResourceManager.requireResource('com.atlassian.auiplugin:aui-select2') #set ( $requestedSearch = "" ) #set ( $requestedSearch = $req.getParameter('requestedSearch') ) #set ( $requestedSpaces = "" ) #set ( $requestedSpaces = $req.getParameter('requestedSpaces') ) #set ( $requestCharacter = "?" ) #if ( $content.getUrlPath().contains("?") ) #set ( $requestCharacter = "&" ) #end #if ( $requestedSearch == "" ) <form class="aui top-label" onsubmit="return false;"> <div class="field-group top-label"> <label for="requested-search">Enter Search Terms:</label> <input id="requested-search" class="text long-field" type="text" name="requestedSearch"> </div> <div class="field-group"> <label for="requestedSpaces">Spaces to search:</label> <select class="select" id="requestedSpaces" name="requestedSpaces" multiple> #set ( $allSpaces = $spaceManager.getAllSpaces() ) #foreach ( $space in $allSpaces ) #if ( $space.isGlobal() ) <option value="$space.key">$space.name - $space.key</option> #end #end </div> <button class="button submit" onclick="window.location = '$content.getUrlPath()' + '${requestCharacter}requestedSearch=' + encodeURIComponent(document.getElementById('requested-search').value) + '&requestedSpaces=' + jQuery('#requestedSpaces').select2('val').join();">Search</button> </form> <script> jQuery("#requestedSpaces").auiSelect2(); </script> #else #set ( $searchTerm = $requestedSearch ) #foreach ( $spaceKey in $requestedSpaces.split(",") ) #set ( $space = $spaceManager.getSpace($spaceKey) ) <p> Pages containing $searchTerm in $space.name </p> #set ( $spacePages = $pageManager.getPages($space, true) ) <table> <tbody> <tr> <th> <p>Page</p> </th> </tr> #foreach ($page in $spacePages) #set ( $pageMarkup = $page.getBodyAsString() ) #if ( ($searchTerm == "blankpage" && $pageMarkup.trim() == "") || $pageMarkup.contains($searchTerm) ) <tr> <td> <p> <a href="$action.getGlobalSettings().getBaseUrl()$page.getUrlPath()">$page.title</a> #if ( $searchTerm == "blankpage" && $page.hasChildren() ) <span class="aui-icon aui-icon-small aui-iconfont-group">has children</span> #end </p> </td> </tr> #end #end </tbody> </table> #end #end
Hi Martin,
Simple answer: No, you can't search for empty pages using standard Confluence search. These are the search plugins in the marketplace - one of them might have what you need.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.