Skip to main content
< All Articles

What is Keyword Query Language and how to use it in SharePoint Online

Posted on October 12, 2021
SharePoint

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 known 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

  • Budget Whatiskqlsharepoint1a
  • Vacation policy Whatiskqlsharepoint2

Managed Properties

  • filetype:PDF Whatiskqlsharepoint3
  • RefinableString06:Budget What 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/2021 Whatiskqlsharepoint7
  • Created=07/15/2020 What 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!

About Me

I’m Greg Zelfond, a U.S. based SharePoint consultant, and I provide affordable out-of-the-box SharePoint consulting, training, and configuration assistance to small and medium-sized businesses all over the world.

Need help?