Introduction
Content By Search Web Part (CSWP) is a new web part introduced in SharePoint 2013. CSWP is similar to Content Query Web Part (CQWP) that is used to display the contents from the search index. Content Search Web Part displays search results that can be easily formatted.
How Content Search Web Part works
The following are the essential things for CSWP:
- Query Builder
- Display Templates.
Advantages of CSWP
The following are the advantages of using the CSWP:
- Displaying data from multiple lists/libraries at the same time.
- Displaying content across site collections.
- Easy to change the look of search results.
- Displays the content from outside that was crawled and available in the search index.
- No more XSLT. HTML and JavaScript files are used to render the information.
Differences between CSWP and CQWP
Content Search Web Part (CSWP) |
Content Query Web Part (CQWP) |
Returns any content from the search index. |
Returns instant content. |
Displays the major versions of the content. |
Displays the major and minor versions of the content. |
Returns results only from the sites that are marked to be indexed. |
Returns results even from the sites that are not marked to be indexed. |
HTML and JavaScript are used to render the information. |
XSLT is used to render the information. |
Create CSWP in SharePoint 2013 Online
In this section you will see how to build a simple query to display all the images from the current site and display as the slideshow in CSWP.
- Navigate to a SharePoint page.
- Click on the Page tab and then click on the Edit button in the ribbon interface.
- Click on the Insert tab and then click on the Web Part button in the ribbon interface.
- Click on the Content Rollup category, select Content Search and then click on the Add button.
- Edit the web part and click on the Change Query button in the Properties section.
- Select Pictures (System) from the “Select a Query” dropdown list.
- Click on the Ok button.
- Select Slideshow from the Control dropdown list in the Display Templates section.
- Click on the Ok button.
- Click on the Save button in the ribbon interface.
- All the pictures from the current site are displayed as a slideshow.
Summary
Thus in this article you saw the basics of the Content Search Web Part in SharePoint 2013.