As I am working through the site and building it, I have come across a small issue I wish to fix.

My current setup, which works for our site well, is using a "Vault" system. One document library with many folders and files. I then use content query to pull certain files to certain pages. This works great.

The problem is, when someone searches for a document, more often than not the directory the document is in appears either at the top or very near the top of the search results. enter image description here

I am trying to hide all folders from appearing and only showing documents or pages, no need to show any document library, lists, sub-sites or folders.

Can this be done?

1 Answer 1


For Content Query Webpart:

  1. Open the tool pane of your webpart.
  2. Expand Query and navigate to Content Type section.
  3. Select Document Content Types under Show items of this content type group dropdown.
  4. Select Document under Show items of this content type dropdown.
  5. Check Include child content types checkbox.
  6. Click Apply and then OK.

enter image description here

For Content Search Webpart:

Add below to your search query:

To show only documents:


To show site pages (.aspx files):


Reference: Limit search results to “Documents”.

  • Thank you. However how do I implement this? I've gone over all the settings I can find. I am not using a webpart, this is to change the site search when they use the search bar in the top right of the page. Jan 24, 2020 at 16:49
  • Check updated answer for content query webpart. Jan 24, 2020 at 17:33
  • Again thank you. But doesn't this only apply to a webpart? Ideally I want the search bar which is on the top right of every sharepoint page to exclude folders. Updated original post to show this. Jan 25, 2020 at 8:47
  • Yes, this is applied to a particular content query webpart. You mentioned that you are pulling files using content query webpart in your question. Jan 25, 2020 at 8:53
  • Correct. But that (which I should of explained) is purely for visual use for those using the site. People will still use the search bar in the top right when they can't find something. I'm more disappointed that there doesn't seem to be a way of filtering these results. The end user sees everything in the search, behind the curtain so to speak. Even the search bar webpart can't be customised to allow custom queries. Jan 25, 2020 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.