Query Rules in SharePoint 2013

This SharePoint search tutorial explains, Query rules in SharePoint 2013 and how to add query rule in SharePoint 2013/2016.

With the help of Query Rules in Sharepoint 2013 without any custom code, we can promote a specific result or even change the ranked result by changing the query. Search Expert or the Search Manager of the organization has the freedom and power to change the search experience and adapt it to the organization’s needs.

Defining the right keywords to be matched on the user queries and mapping the conditions with the relevant actions is easy but the process must undoubtedly be well managed. The management of the query rules should definitely be part of your SharePoint 2013 search governance strategy.

A query rule can specify the following three types of actions:

Add Promoted Results
Add one or more groups of results, called result blocks
Change the ranking of results

How to Create Query Rule in SharePoint 2013

Let’s take a scenario where an organization is maintaining the list of glossary terms managed in the organization. When we search in google “meaning of activity”, it automatically recognizes that user wants to know the meaning of the word ‘activity’ and it highlights its meaning at the top and displays the rest of the results in the bottom.

query rules in sharepoint 2013

SharePoint also provides this feature using ‘Query Rule’ feature.
By default, when we search for ‘definition of activity’ or ‘meaning of activity’ it returns the results including keywords definition and activity.

query rules in sharepoint online

We have managed the list of glossary terms in a list as shown below,

query rules in sharepoint 2016

Go to Search Setting of the Search Center site and click on ‘Query Rules’
Select ‘Local SharePoint Sites’ under click on ‘Add Query Rule’
Name it as ‘Glossary Rule’ and select ‘Query Contains Action Term’ as a Query condition as shown below.

how to create query rules in sharepoint 2013

Add ‘definition of;meaning of’ under the Action Terms phrases. So that whenever end-user search for ‘definition of activity’ it excludes the terms definition of and search only for ‘activity’ in the glossary list.

Click on Change rule query and it will open this window

Select the ‘Glossary’ result source. (You need to create the glossary results source first which returns the results only from the glossary list)

Under the keyword filter select ‘{SubjectTerms} – the unmatched query terms’ and click on ‘Add property filter’

how to create query rules in sharepoint 2016

Click on ‘Add Result Block’

how to create query rules in sharepoint online

Click ok
Publishing section defines from which period of time from start date to end date this query rule should be active.

query rules in sharepoint

Click on ok.
Now go to your search center and search for ‘definition of activity’

how to create query rules in sharepoint

You can see that it promoted the results from the glossary list.

Here, we learned how to work with Query Rules in SharePoint 2013/2016.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.