How do I exclude all attachments (images, pdfs, etc.) from both the global and space-level search in Confluence?
Asked by Jesse Seldess:

I can't find any information online about customizing the Confluence search to exclude images and all other attachments. I know that users can set a filter on the advanced search page, but I'd like the default search to return only pages (no images, other attachments, blogs, etc.).

I'd appreciate any and all ideas.

Best,

Jesse


Answers:
author: Davin Studer
body: You can exclude attachments from being indexed. Here is the documentation for that.

[](https://confluence.atlassian.com/display/CONFKB/How+Do+I+Disable+Indexing+of+Attachments)<https://confluence.atlassian.com/display/CONFKB/How+Do+I+Disable+Indexing+of+Attachments>

comments: author: Jesse Seldess
body: Thanks, Davin. I've looked through that document before. It seems to be about excluding Word, PowerPoint, Excel, and PDF files, but I'm interested in excluding all images as well. Is that also possible by editing the atlassian-plugin.xml?


author: Davin Studer
body: Do you want users to not ever be able to search for these, or just not by default using the top right search box? If you just want to make sure that the top right search bar will by default only show pages then you can add this Javascript to the global custom html. This will put in a hidden field in the form element of the top right search box that says to only return pages.

```
AJS.toInit(function(){	AJS.$('#quick-search').append('&lt;input type="hidden" name="type" value="page"&gt;');});
```


author: Jesse Seldess
body: This is exactly what I was looking for. Thanks very much, Davin! It works perfectly for the global search.

I tried to apply this to the search box in the pagetree area (documentation theme) but didn't have any luck. Instead, I hid the default search box in the space stylesheet and configured the doc theme to include the {search-box} macro, which lets me filter by type.


author: Bob Kennedy
body: I tried this too and it seemed to do nothing. Did you apply the custom html to header, body, or footer?


author: Davin Studer
body: It should be in the after body section. Also, you need to wrap it in script tags.\<script type="text/javascript"\>AJS.toInit(function(){...});\</script\>


author: Jesse Seldess
body: David, I found a solution for filtering page tree search results. A bit of a hassle, but it works.

In each space, we did the following:

1. We configured the Documentation theme (**Browse \> Space Admin \> Themes Configure them)** , adding a custom search macro to the page tree area. We also used the html macro to tag the search box with an html id, so that we can target it in the space styesheet.

|------------------------------------------------------------------------------------------------------|
| ``` {html}<div id="customsearchbox">{html}{search-box:space=console|type=page}{html}</div>{html} ``` |

2. We editing the space stylesheet (**Browse \> Space Admin \> Stylesheet**) to hide the default search box and apply our styling to the custom search box:

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ``` /****************************************Space-specific search boxDefault search box is hidden; custom is included in the doc theme*****************************************/#pagetreesearch {    display: none;}#customsearchbox {   margin: 10px 0 10px 20px;   min-width: 230px;}#customsearchbox form.confluence-searchbox.adaptavist-searchbox {   white-space: nowrap;   margin: 1.5em 0 0 0;   position: relative;}#customsearchbox input[type=text],#customsearchbox input[type=submit] {   margin: 0 8px 8px 0;   border: 1px solid #CCCCCC;   color: #666666;   max-width: 165px;   padding: 4px 5px;   height: 2.14285em;   line-height: 1.4285;   box-shadow: inset 0 1px 3px #CCC;   width: 100%;   border-radius: 3.01px;   font-size: inherit;   font-family: 'Open Sans', Arial, sans-serif;   box-sizing: border-box;}#customsearchbox input[type=submit]{   background: #f2f2f2;   background: -moz-linear-gradient(top,#fff 0,#f2f2f2 100%);   background: -ms-linear-gradient(top,#fff 0,#f2f2f2 100%);   background: -o-linear-gradient(top,#fff 0,#f2f2f2 100%);   background: -webkit-linear-gradient(top,#fff 0,#f2f2f2 100%);   background: linear-gradient(top,#fff 0,#f2f2f2 100%);   text-decoration: none;   text-shadow: 0 1px 0 white;   vertical-align: baseline;   min-width: 0;   width: auto;   box-shadow: none;}? ``` |


Tags: confluence-administration