Skip to main content

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):

  1. Free text words and phrases
  2. Managed Properties
  3. Operators

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

  • BudgetWhatiskqlsharepoint1a
  • Vacation policyWhat is Keyword Query Language (KQL)

Managed Properties

  • filetype:PDFWhatiskqlsharepoint3
  • RefinableString06:BudgetWhat is Keyword Query Language (KQL)

In case you are wondering what the hell is a managed property – check out this post.

Howtocreatemanagedproperty9

Operators

  • red AND Blue (this is an example of Boolean operators I described here)Whatiskqlsharepoint5
  • Created>07/08/2021Whatiskqlsharepoint7
  • Created=07/15/2020What is Keyword Query Language (KQL)

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.

What is Keyword Query Language (KQL)

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.

What is Keyword Query Language (KQL)

The Verdict

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!

You may also like

How to create a Managed Property in SharePoint Online

September 21st, 2021

You may also like

Managed Metadata vs. Managed Properties

August 12th, 2021

You may also like

Automatically created Managed Properties in SharePoint Online

July 13th, 2021

Need SharePoint Help?

Hourly consulting, training and configuration services are available

Learn More