What is Keyword Query Language and how to use it in SharePoint Online
In one of my earlier posts, I explained how you could use Boolean Search Operators when searching for content in SharePoint. This allowed you to expand or limit results based on some simple operators like AND, OR, or NOT. That Boolean Query example is one of the basic concepts behind something called Keyword Query Language, also knows as KQL. If you would like to build more advanced searches and queries in SharePoint – you need to understand what it is and how it works. So I would like to take this opportunity and explain to you, my loyal blog followers, what KQL is all about, and how to use it in SharePoint.
What is Keyword Query Language?
KQL is a set of keywords one can use to specify the queries in the SharePoint search. It can consist of the following elements (Source: Microsoft Documentation):
- Free text words and phrases
- Managed Properties
Keyword Query Language Examples
Below please find some examples of the Keyword Query Language (KQL) for each of the elements mentioned above.
Free Text Words and Phrases
- Vacation policy
In case you are wondering what the hell is a managed property – check out this post.
- red AND Blue (this is an example of Boolean operators I described here)
Where can you use Keyword Query Language?
There are two locations where you can use KQL in SharePoint.
Any Search Box in SharePoint
You can use KQL in any search box, whether it is at a library level, site level, Hub Level, or the whole SharePoint. By the way, check out this article and learn about the difference in terms of search results in these 4 locations.
Highlighted Content Web Part (HCWP)
We now have a way to use KQL within the HCWP Web Part. So if you want to use advanced filtering and build advanced KQL queries – this could prove a compelling option.
Knowing and understanding Keyword Query Language (KQL) syntax will allow you to construct some interesting queries when searching for content in SharePoint Online. Embrace it!
Need SharePoint Help?
Hourly consulting, training and configuration services are availableLearn More