Confluence - search result for empty pages

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

2 answers

This widget could not be displayed.

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.

This widget could not be displayed.
Stephen Deutsch Community Champion Nov 04, 2016

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

569 views 7 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you