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

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

2 answers

1 accepted

0 vote
Davin Studer Community Champion Jun 26, 2014

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

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?

Davin Studer Community Champion Jun 29, 2014

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('<input type="hidden" name="type" value="page">');
});

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.

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

Davin Studer Community Champion Dec 09, 2014

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>

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 box
Default 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;
} 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

1,783 views 25 10
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