Confluence - search result for empty pages
Asked by Martin James:

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](https://confluence.atlassian.com/doc/confluence-search-fields-161188.html) page advises that you can search for body content.

search.png  
[](https://community.atlassian.com/t5/Confluence-questions/Confluence-search-result-for-empty-pages/qaq-p/431141?attachment-id=5713){#link_11862dfb9c641d}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/73053/1/search.png){#display_11862dfb9c641d_0}


Answers:
author: Stephen Deutsch
body: 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 = "&amp;" )#end#if ( $requestedSearch == "" )  &lt;form class="aui top-label" onsubmit="return false;"&gt;    &lt;div class="field-group top-label"&gt;      &lt;label for="requested-search"&gt;Enter Search Terms:&lt;/label&gt;       &lt;input id="requested-search" class="text long-field" type="text" name="requestedSearch"&gt;    &lt;/div&gt;    &lt;div class="field-group"&gt;      &lt;label for="requestedSpaces"&gt;Spaces to search:&lt;/label&gt;      &lt;select class="select" id="requestedSpaces" name="requestedSpaces" multiple&gt;      #set ( $allSpaces = $spaceManager.getAllSpaces() )      #foreach ( $space in $allSpaces )        #if ( $space.isGlobal() )          &lt;option value="$space.key"&gt;$space.name - $space.key&lt;/option&gt;        #end      #end    &lt;/div&gt;    &lt;button class="button submit" onclick="window.location = '$content.getUrlPath()' + '${requestCharacter}requestedSearch=' + encodeURIComponent(document.getElementById('requested-search').value) + '&amp;requestedSpaces=' + jQuery('#requestedSpaces').select2('val').join();"&gt;Search&lt;/button&gt;  &lt;/form&gt;  &lt;script&gt;    jQuery("#requestedSpaces").auiSelect2();  &lt;/script&gt;#else  #set ( $searchTerm = $requestedSearch )  #foreach ( $spaceKey in $requestedSpaces.split(",") )    #set ( $space = $spaceManager.getSpace($spaceKey) )    &lt;p&gt; Pages containing $searchTerm in $space.name &lt;/p&gt;    #set ( $spacePages = $pageManager.getPages($space, true) )    &lt;table&gt;      &lt;tbody&gt;        &lt;tr&gt;          &lt;th&gt;            &lt;p&gt;Page&lt;/p&gt;          &lt;/th&gt;        &lt;/tr&gt;      #foreach ($page in $spacePages)        #set ( $pageMarkup = $page.getBodyAsString() )        #if ( ($searchTerm == "blankpage" &amp;&amp; $pageMarkup.trim() == "") || $pageMarkup.contains($searchTerm) )          &lt;tr&gt;            &lt;td&gt;              &lt;p&gt;                &lt;a href="$action.getGlobalSettings().getBaseUrl()$page.getUrlPath()"&gt;$page.title&lt;/a&gt;                #if ( $searchTerm == "blankpage" &amp;&amp; $page.hasChildren() )                  &lt;span class="aui-icon aui-icon-small aui-iconfont-group"&gt;has children&lt;/span&gt;                #end              &lt;/p&gt;            &lt;/td&gt;          &lt;/tr&gt;        #end      #end      &lt;/tbody&gt;    &lt;/table&gt;  #end#end
```


author: Rob Woodgate
body: Hi Martin,

Simple answer: No, you can't search for empty pages using standard Confluence search. These are [the search plugins in the marketplace](https://marketplace.atlassian.com/search?q=search) - one of them might have what you need.


Tags: search