Content search web part for a specific SharePoint list\library

This is supposed to be my first blog post on SharePoint 2013. This is about the new and the much spoken about Content search web part in SharePoint 2013. While I was working on it, I wanted to load the list items from a particular library in the content search web part. I could not find much help by googling on how to configure the query builder of the CSWP to target a specific SharePoint library.

You may also like to have a look at the below blog posts regarding Content Search Web Parts:

In this post I will explain how to target a particular library as well as a list in a CSWP by modifying its query through various options.

a. Add a CSWP to your page and edit the web part to view its tool pane. In the tool pane of the web part click on Change query to open the query builder modal window as shown below:


b. As you see in the above screen shot, the default configuration in the query builder is to show the recently edited items in the current site.

c. In order to display the list items from a library, select “Documents” from Select a query and select “Specify a URL” from Restrict by app and enter the URL of your library in the text that appears immediately below the drop down as shown in the below screenshot.


Note: While entering the URL of the library, please note that the URL should not have any “%20” in it and the URL should only be up to the library’s name. For e.g. if the URL of the library is:, please change it to Aricles/ while entering.

Once you finish, the results would be shown in the Search result preview.

d. Click OK and you should see your web part displaying the document links from the document library in your CSWP.

Now let us see how to accomplish the same requirement for a list.

a. In the same web part, follow the same procedure to edit the query builder of the web part.

b. Replace the URL of the library with your list URL. You should be seeing that no results are returned in the Search result preview section.

c. Click on “Switch to Advanced mode”, you should be seeing the below screen:


d. As you see in the query text textbox, the file extensions of the results are being queried which restricts the results to documents alone and avoids list items.

e. Remove the text that checks for file extensions as shown below:


f. Now click on “Test query” and you should see the list items from the SharePoint list returned.