-->

Thursday, 28 November 2013

Query Rules in SharePoint 2013




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 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 Add Query Rule:
Let’s take a scenario where 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 top and displays the rest of the results in bottom.


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.
We have managed the list of glossary terms in a list as shown below,


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



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’



Click on ‘Add Result Block’



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



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

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


Happy SharePointing !!