Forum Discussion
Can Search Result Web Part be used to show items from a specific list?
We have a list of customers. The "Title" column contains the customer name. The list is based on a site content type "Customer".
A Search Result Web Part has been added on a page and the query has been changed to:
- Select a query = "Items matching a content type (System)"
- Restrict by app = "Current site collection" (have tried also without).
- Restrict by content type = "Customer"
No items from the customer list are found! Are we doing something wrong here? Any hints?
4 Replies
- Mikael SvensonIron Contributor
As stated by other using path: can limit you to just one particular list, but you will get the forms as well. To only return items you can do something like:
path:http://server/site/yourlist contentclass:sts_listitem
If like you do, have the content type, then you can get all items regardless of the list with the secret:
spcontenttype:mycontenttype
Using contenttype does not work as it contains garbage info beside the ct name, which is why you use SPContentType in the filter.
Combine this with path, and you get that content type from a list with more than one. And it's more correct to use = instead of : if you know the exact name, but usually they work just the same as long as you don't have more ct's starting with the same name.
As easy as that, and feel free to get my book as Dean_Gross said :)
- Dean_GrossSilver Contributor
Mikael Svenson has a book https://www.bookdepository.com/Sharepoint-Search-Queries-Explained-Mikael-Svenson/9781505887037 with lots of great examples about how to so queries like this.
His blog at http://www.techmikael.com/ also has lots of very good posts about searching.
- John Aage AndersenIron ContributorThanks Pieter
Using the "path:" statement in the query definition, we got it to take only the items in the Customers list!