Using SharePoint KQL syntax in Solution Profiles
Who is this article for?
Administrators and Advanced Users.
Access the Administration Client.
Ideagen Mail Manager Enterprise Live: Solution Profiles uses SharePoint's Keyword Query Language (KQL) syntax to create simple or complex queries that search against specific managed properties, restrict to specific URLs, and return only specific result types.
Understanding KQL syntax
Solution Profiles uses the KQL syntax of SharePoint. You can write queries to search against specific managed properties, restrict to specific URLs, and return only specific result types such as document libraries/lists, folders/document sets, or sites/site collections, or combinations of these.
Developing and testing queries
The content search query web part in SharePoint 2013 is a good way to develop these queries and test the results.
To use a tested query in Solution Profiles:
- Develop and test your query in the SharePoint content search query web part.
- Copy the working query.
- Paste it into the Ideagen Mail Manager Enterprise Live: Solution Profile item query field.
Creating simple queries
The following examples demonstrate basic KQL queries for common scenarios.
Getting sites or site collections
This query retrieves only sites or site collections called 'Project A':
Title:Project A AND ((contentclass="sts_site" OR contentclass="sts_web"))Getting document libraries
This query retrieves only 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-serverGetting folders or document sets
This query retrieves 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"Getting multiple result types
This query retrieves document libraries and sites called 'Project A':
Title:Project A AND ((contentclass="STS_List_DocumentLibrary" OR contentclass="sts_web" OR contentclass="sts_site"))Creating complex queries
You can combine multiple criteria to create more sophisticated queries.
Using multiple metadata filters
This query retrieves all folders or document sets under the URL 'http://app-server/subsite1' that have a status of 'Open', 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"Adding date range filters
This query extends the previous example to retrieve only project document sets created between 1 October 2014 and 1 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))Using property bags in queries
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.
To use property bags in search queries:
- Configure and set the property correctly.
- Perform a full crawl to create a crawled property.
- Map the crawled property to a managed property.
- Perform an additional crawl.
- Use the managed property in your search queries.
The article Using SharePoint PropertyBag in the Context of Search by Nicki Borell provides a good explanation and relevant references.
Example query using property bags
This query retrieves all project sites that have a status of active and are engineering projects, using managed properties stored on each site/site collection:
((Path:http://app-server/projects AND contentclass=((contentclass="sts_site" OR contentclass="sts_web"))) AND ((ProjectStatus:Active) AND (ProjectType:Engineering)))Note: Solution Profiles harnesses SharePoint KQL queries, allowing you unending flexibility and possibilities for querying your SharePoint and Office 365 environment.