SharePoint Content search web part is a very useful web part where we can display items based on various search criteria. In this post, we will discuss how we can filter records based on the query string parameter value in a content search web part in SharePoint 2013/2016/Online.
Here in this example, we will display items from a particular list based on a query string parameter. And we will filter here in the Title column. Here I have a SharePoint 2013 list which has more than 10 items in it. I want to show items based on a query string parameter value in a content search web part.
For this, I have created a SharePoint 2013 web part page and then added a content search web part in the page from the Content Rollup web part categories.
Then Edit the web part and click on Change query in the web part properties.
This will open the Build Your Query wizard where you can build your query. In the basic tab, I have modified the filter. In the Select a query I have selected “Items related to current user (System)“.
In the Restrict by an app, I have selected Specify a URL and I have mentioned by list URL. This I have chosen because I want the records to come from a particular list only not from the whole site. You can choose according to your requirement.
In the Restrict by tag, I select Don’t restrict by any tag. The whole should look like below:
Then click on Switch to Advanced Mode link in the same dialog box. By default you should see like below:
Now in the Keyword filter select “Value of a parameter from URL“.
Now in the Property filter, select “Show all managed properties” as shown in the fig below:
Now in the Property filter choose “Title” and then Contains and then in the Select Value choose “Value of a parameter from URL”. It should look like below:
The expression will appear like below:
Title:{QueryString.MyParameter1}
Here MyParameter1 is the query string parameter id. You can change it to any name you want. Here I have changed like below:
Title:{QueryString.ItemTitle} and it should looks like below:
Now Save the page and browse the URL like below:
https://onlysharepoint2013.sharepoint.com/Pages/TestSearch.aspx?ItemTitle=Items
So it will display items whose Title contains the word “Items” as shown in the fig below:
You may like following SharePoint 2013 search tutorials:
- How to define Search scopes in SharePoint 2013 Using Result Sources?
- How to customize search results look by using result types and display templates in SharePoint Online and SharePoint 2016/2013?
- Calling SharePoint Search Using REST from JavaScript
Hope this will be helpful to SharePoint 2013/2016/Online Content Search WebPart with Query String.
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SPGuides.com