You are here: OnePlaceLive Services > Solution Profiles service > SharePoint KQL Syntax examples

SharePoint KQL Syntax and resources

OnePlaceLive uses the KQL syntax of SharePoint https://msdn.microsoft.com/en-us/library/office/ee558911.aspx . Simple or complex queries can be written to search against specific managed properties, restrict to specific URLS and to return only specific result types i.e. document libraries/lists, folders/document sets or sites/site collections or combinations of these.

The content search query web part in SharePoint 2013 is a good way to develop these queries and test the results https://msdn.microsoft.com/en-us/library/office/jj163789.aspx . Once the query is working as expected it can be copied and pasted into the OnePlaceLive solution item query field.

Simple Examples:

This example gets just sites or site collections called ‘Project A’:

Title:Project A AND ((contentclass="sts_site" OR contentclass="sts_web"))

This example gets just document libraries called ‘Project A’ under the URL ‘http://app-server’:

Title:Project A AND contentclass="STS_List_DocumentLibrary" AND “allitems.aspx” AND Path:http://app-server

This example gets all folders or document sets called ‘Project A’ under the URL ‘http://app-server’:

Title:Project A AND Path:http://app-server AND contentclass="sts_listitem_documentlibrary"

This example gets document libraries and sites called ‘Project A’:

Title:Project A AND ((contentclass="STS_List_DocumentLibrary" OR contentclass="sts_web" OR contentclass="sts_site"))

More complex Examples

This example gets all folders or document sets under the URL ‘http://app-server/subsite1’ that have a status of ‘Open’ and a Client called “Client A” and are in ‘Australia’:

Status:Open AND Client:Client A AND Country:Australia AND Path:http://app-server/subsite1 AND contentclass="sts_listitem_documentlibrary"

 

This example extends the query above and uses a date range query to refine the query even more to get all project document sets created in the date range 1st October 2014 to 1st March 2015:

((Status:Open) AND (Client:Client A) AND (Country:Australia) AND (Path:http://app-server/subsite1) AND (contentclass="sts_listitem_documentlibrary") AND (Created=2014/10/01..2015/03/01))

 

SharePoint 2013 allows you to use hidden property bags for storing metadata at different levels of hierarchy within SharePoint. For example, you can store metadata in a Property Bag at a Site or Site Collection level. If the Property has been configured/set correctly and a full crawl performed, the property becomes a Crawled Property.

 

At this point, you can map the Crawled property to a Managed Property, perform an additional crawl and use it in your search queries.

The article Using SharePoint PropertyBag in the Context of Search by Nicki Borell provides a good explanation and relevant references.

 

The example below gets all project sites that have a status of active and are engineering projects as these managed properties are stored on each site/site collection allowing us to query them:

((Path:http://app-server/projects AND contentclass=((contentclass="sts_site" OR contentclass="sts_web"))) AND ((ProjectStatus:Active) AND (ProjectType:Engineering))

 

In summary, OnePlaceLive harnesses SharePoint KQL queries allowing you unending flexibility and possibilities for querying your SharePoint & Office 365 environment