Content by Search Web Part
The Content by Search web part (CSWP) is a new web part available to SharePoint 2013 Enterprise edition. In previous versions of SharePoint, you could rollup your SharePoint content using the Content by Query Web Part (CQWP) from within the current site collection. The CSWP does not replace the CQWP but is an additional web part that enables you to display rolled up SharePoint content from across the farm using the search results.
The CSWP can be added to a web part page and then configured from scratch, or you can add pre-configured web parts such as the ‘Recently Changed Items’ or ‘Popular Items’ web parts which can then be further refined.
Firstly, in order for the CSWP to return aggregated SharePoint content, you must first make sure that you have a successful crawl of your SharePoint content since the CSWP relies on the search crawl being completed.
Adding the Content by Search Web Part
Before we being, you must first add a CSWP to your SharePoint page.
1. Click Edit on the Page ribbon.
2. Click the Insert ribbon and then click Web Part.
3. From the Content Rollup category, select ‘Content Search’ and then click Add.
4. Choose the drop down arrow of the Content by Search web part and click Edit web part.
Configuring the Query
Now that you have added the CSWP to the page, we can configure the query to return the desired results. The CSWP can aggregate content from any list or library from within the SharePoint farm and then filtered based upon the type of content or by meta data. Once the query has been built, you will be able to configure the display options.
To configure the query:
1. From the toolpane of the content by search web part, click the ‘change query’ button.
2. The CSWP dialog displays allowing you to configure the query using four different tabs.
3. The Basics tab displays some configuration options on the left hand side pane and preview results in the right hand pane. This is useful allowing you to see what content your web part will display prior to completing the configuration.
4. The first field in the Basics tab is the ‘Select a query’ field. The queries that you can select from are ‘Result Sources’ which are configured within the Search Service application through SharePoint Central Administration or via the Site Settings.
5. The example I will give is a configuration to rollup Tasks from Task lists. One thing we know about Tasks is that they are created using the Task content type of a content type that derives from Tasks. Therefore, I will select ‘Items matching a content type’ as my result source.
6. You can then choose your scope using the ‘Restrict by app’.
7. Although, the field is not in the correct order, the next field to set would be the ‘Restrict by content type’. Note that this field will change depending on your Result Source. Set the option to Task to rollup tasks. The preview pane should show the tasks that you will be aggregating.
8. You can then further restrict the results using the Restrict by tag or Add addition filter options.
9. You can further refine the results using the Refiners tab. An example would be filtering by Author or Assigned To.
10. The Settings tab allows you to set certain settings that affect the load behaviour of the web part among others.
11. The first setting it whether to use Query Rules. The Query Rules are set within the Site Settings and can be used to fine tune the search results.
12. Finally the Test tab provides you with the query text which can be used to test the search results.
Configuring the Display of your results
Now that the scope and the query is set, we need to make the results look better. The CSWP toolpane contains Display Templates depending on how you want to display the results. There are three types of control. List, List with Paging or Slideshow. The Item will field will then show variations of the displays using the display templates.
Once you have selected the display template, expand the Property Mappings and populate the managed property fields with the columns that you wish to display. In my example I have configured the display settings for a Task List.
The results are now shown within the Web Part.
Clicking the hyperlink for each result will navigate you to the item itself.
<Brett/>