Posted on April 21, 2016|by: Johnny Bouder| 1 Comment

One of the most powerful (and most overlooked) features in SharePoint 2013 is SharePoint Search. Unfortunately, few people realize just how powerful it can be. I suspect that this is because most people just envision a search box and search results when, in fact, is that there is so much potential with SharePoint Search–huge potential when used properly!

Take document rollup, for example. This functionality allows you to view streaming data from multiple Document libraries all in one place.

In this example, I’ll show how you can roll up all your Word and PDF Documents in a site collection into a Web Part.

To make this work, there are 3 things you will need:

• Content Search Web Part: A very powerful new Web Part that essentially allows you to display Search Results based on Search Criteria, Display Templates, and a few other settings.
• Control Template: A specifically formatted HTML file that provides a template for displaying the general look of your search results. This includes things like the body of results, paging, etc.
• Item Template: Another specifically formatted HTML file that provides a template for displaying individual items within your search results.

The recommended process for creating a Display Template is to create a copy of an existing template and customize it to your needs. Fortunately, Microsoft has provided lots of examples out of the box. Here are the general steps:

1. Navigate to Master pages >> Display Templates >> Content Web Parts
2. Download one of the HTML files
3. Rename and Edit the file in any text editor
4. Upload the new file to the same folder

When the file is uploaded a corresponding JavaScript file will be created. This file is the JavaScript equivalent, which is actually used by the Content Search Web Part to interpret and display the results. It’s important to remember that the JavaScript files should never be modified directly–always make changes to the HTML file and upload.

To get back to my example, I first made a copy of the Control_ListWithPaging.html file. The only thing I did to modify this file was move the paging controls to the bottom left. Next, I made a copy of the Item_TwoLines.html file. I made a few customizations to this file to make the items display in more of a list-view-like display as opposed to a block view. I also added the Modified date. Finally, after uploading these files, I added a Content Search Web Part, set the Display Templates, and configured Search Criteria. For my Search Criteria, I set up my query to include all items in the current site collection that are Word and PDF file types.

To implement this example, follow these steps (assuming you have documents already in your site collection and assuming those documents have been crawled):

1. Download and extract the files from
2. Navigate to the top-level Site Settings page of your site collection
3. Click “Master pages” >> “Display Templates” >> “Content Web Parts”
4. Upload each file one by one and Publish a Major Version
5. Navigate to the page where the Web Part will reside and Edit the page
6. Click to Add a Web Part, select “Content Rollup” category, select “Content Search,” and click “Add”
7. Edit the Web Part
8. Click the “Change Query” button
9. Click “Switch” to Advanced Mode
10. Paste the following into the Query Text Box: Path:{SiteCollection.URL} AND (FileType:docx OR FileType:pdf)
11. Click “OK”
12. Set Number of items to show something like 15
13. Set the Control drop down to “List with Paging 2”
14. Set the Item drop down to “Document Rollup”
15. Click “OK”

If all went well, you should see something like this:
A few things to note:

Because search data is stored in an index on a server, performance of this Web Part will be MUCH better than it would be if you queried the data directly from the database, especially if you’re pulling from a large number of sub-site and document libraries
You will only see documents in the Web Part if they have been crawled. Out-of-the-box items will generally be crawled every 15 minutes. If this view should be more up-to-date than that, I would suggest enabling Continuous Crawl and setting the crawl rate to something more frequent.
Additional fields can be displayed in the view. However, those columns would need to be included in Managed Properties and the Item Template would need to be updated.

It may seem like a lot of steps to get this working, but once you do a few of these they become very easy. It’s also much better than trying to scour the internet for documentation on using JSOM.

A few other great articles on building search-based solutions using SharePoint 2013 Search:

Using the Content Search web part (and understanding SP2013 search)
The Content Search Web Part to Display SharePoint Subsites
How to set up a product-centric website in SharePoint Server 2013

Hopefully this has been helpful. Enjoy!

Filed in: Collaboration, Sharepoint, Tips & Tricks, Web

One Trackback +

  1. […] on SharePoint: • Creating a Document Rollup Using SharePoint 2013 Search • Angular and SharePoint Integration • Color Coding a SharePoint 2013 List the Right Way […]

Your email is kept private. Required fields are marked *