When I was working with Content Search web part in one of my SharePoint sites, I experienced a problem where the search result for list items is displayed along with list views.
In this article, I will show you how to remove the list views in CSWP search results.
For better understanding, consider a list, EMPINFO from which you want to show the items in CSWP. To show specific list items, you might have carried out the below steps
- Edit the CSWP and click on Change query
- Choose Documents (System) in Select a query
- Choose Specify a URL and enter the list URL for Restrict by app
- Switch to Advanced mode and remove the highlighted file extension query text.
- You can see AllItems.aspx view along with the list items in search results.
To remove the view, you can follow any one of the below step:
- Select “Only return items “ in keyword filter and click on “Add Keyword Filter”
- Just append [contentclass:STS_ListItem] after Path in Query text