Sunday, June 16, 2013

SharePoint 2013 Keyword Query (KQL) Content Class Property Restrictions

Using property restrictions in your KQL queries, you can restrict your search to only pull back certain things like calendar events for instance. This is a very powerful way to limit search results and get exactly what you are looking for.

You can use these in your query like this:
"lunch contentclass:STS_ListItem_Events"
This will return only calendar events with the word "lunch" in them.  Pretty powerful and pretty simple.

Here is a list of available content class items:
  • STS_Site –  Site Collection
  • STS_Web  –  Site (Web)
  • STS_List_850  –  Page Library
  • STS_ListItem_850  –  Page
  • STS_List_DocumentLibrary  –  Document Library
  • STS_ListItem_DocumentLibrary  –  Document Library Items
  • STS_List  –  Custom List
  • STS_ListItem  –  Custom List Item
  • STS_List_Links  –  Links List
  • STS_ListItem_Links  –  Links List Item
  • STS_List_Tasks  –  Tasks List
  • STS_ListItem_Tasks  –  Tasks List Item
  • STS_List_Events  –  Events List
  • STS_ListItem_Events  –  Events List Item
  • STS_List_Announcements  –  Announcements List
  • STS_ListItem_Announcements  –  Announcements List Item
  • STS_List_Contacts  –  Contacts List
  • STS_ListItem_Contacts  –  Contacts List Item
  • STS_List_DiscussionBoard  –  Discussion List
  • STS_ListItem_DiscussionBoard  –  Discussion List Item
  • STS_List_IssueTracking  –  Issue Tracking List
  • STS_ListItem_IssueTracking  –  Issue Tracking List Item
  • STS_List_GanttTasks  –  Project Tasks List
  • STS_ListItem_GanttTasks  –  Project Tasks List Item
  • STS_List_Survey  –  Survey List
  • STS_ListItem_Survey  –  Survey List Item
  • STS_List_PictureLibrary  –  Picture Library
  • STS_ListItem_PictureLibrary  –  Picture Library Item
  • STS_List_WebPageLibrary  –  Web Page Library
  • STS_ListItem_WebPageLibrary  –  Web Page Library Item
  • STS_List_XMLForm  –  Form Library
  • STS_ListItem_XMLForm  –  Form Library Item
  • urn:content-class:SPSSearchQuery  –  Search Query
  • urn:content-class:SPSListing:News  –  News Listing
  • urn:content-class:SPSPeople  –  People
  • urn:content-classes:SPSCategory  –  Category
  • urn:content-classes:SPSListing  –  Listing
  • urn:content-classes:SPSPersonListing  –  Person Listing
  • urn:content-classes:SPSTextListing  –  Text Listing
  • urn:content-classes:SPSSiteListing  –  Site Listing
  • urn:content-classes:SPSSiteRegistry  –  Site Registry Listing
Thanks to a post from Marc Schuricht and a post from Jeremy Jameson.

Enjoy!

5 comments:

  1. I do have a question. I have a column called ReceivedDate. This is a time/date column type. I want to create a result source that only shows documents with a received date. How do I exclude all documents with a received date?

    ReplyDelete
    Replies
    1. Jasper,

      You'll need to make sure the column is mapped to a managed property first. After that, I'm pretty sure you can not search for NULL or empty, but since its a date, you could probably do something like this "ReceivedDate>01/01/1900'. This would return anything with a ReceivedDate (assuming your items don't go back that far) and should ignore anything that does not have a date.

      Delete