In many cases, customers complain about “Sharepoint Search doesn’t work“. While it is a generic objection, and there are many things to evaluate, one of the recommendations I can give is to consider the usage of search Query Rules in SharePoint and Office 365.
Search Query Rules in SharePoint and Office 365 help to support the users’ search intent, by creating pre-defined rules which apply to the user queries.
A Query Rule always consists of three different settings:
- Query condition(s): Define the conditions when a user’s search box query makes this rule fire. You can specify multiple conditions of different types, or remove all conditions to fire for any query text.
Please note that every query condition becomes false if the query is not a simple keyword query, such as if it has quotes, property filters, parentheses, or special operators.
- Action(s): When your Query Rule fires, it can enhance search results in three ways:
- add promoted results above the ranked results;
- add blocks of additional results. Like normal results, these blocks can be promoted to always appear above ranked results or ranked so they only appear if highly relevant;
- change ranked results, such as tuning their ordering.
- Publishing settings: These settings control when the rule can fire. If the rule is not active, it never fires. The start date is when you want it to start firing. The end date is when you want it to stop firing. The review date is when you want the contact to review the rule.
Promoting results by Query Rules
After this quick introduction, let’s see how a Query Rule looks like in practice.
1 – Decide WHERE to create the Query Rule
You can create Query Rules on three levels of SharePoint’s site structure:
- farm (SharePoint on-prem) / tenant (SharePoint Online)
- site collection
When you create a Sharepoint Search Query Rule on any level, the levels below inherit it.
On SharePoint farm level:
- Go to Central Administration / Service Applications / Search Service Application
- Open “Query Rules” under “Queries and Results“
In SharePoint Online:
- Go to the SharePoint Admin Center.
- Open the Search Administration settings from the left-side menu.
- Click on “Manage Query Rules“.
In a site collection:
- Go to the Site Settings page.
- Under Site Collection Administration, open “Search Query Rules“.
In a site:
- Go to the Site Settings page.
- Under Search, open “Query Rules“.
(Note: yes, the naming is quite inconsistent, but these really mean the same settings, on different level.)
2 – Select the Result Source
Query Rules are always connected to a Result Source – the first step is to select it from a dropdown menu. After selecting one, you get the list of Query Rules assigned to the selected Result Source. Also, you can create a new Query Rule here.
Note: If you want your Query Rule to fire for each Result Source, you have to scroll down to the bottom of the list, and you find the “All Sources” option there.
3 – Define the Query Condition
A Query Rule can have one or more conditions, in various types:
- Query matches exactly + phrase(s)
- Query contains action term + phrase(s) list or a matching dictionary in term store
- Query matches dictionary exactly
- Query more common in source (more likely used in another Result Source) + another Result Source
- Result Type commonly clicked + Result Type
- Advanced Query Text match
Two or more conditions can be combined, in which case there’s an OR operator between each.
Let’s say we want the Query Rule to fire when the query contains the word “marketing”. In this case, your settings have to be like this:
4 – Actions
Thee are several actions that can be taken when a Query Rule is being created. The one I’d like to introduce in this post is to promote a result – see the other options in later posts.
When we want to promote a result, we have to click on “Add Promoted Results” under “Actions” on the Query Rule page.
Let’s say, we want to display the Marketing Portal as a promoted result whenever the query contains the word “marketing”. In this case, the Action has to contain a promoted result like this one:
5 – Save and enjoy
After saving the settings, the new Search Query Rule will be immediately applied, and you can start using it.
For example, when searching for “marketing reports”, the result set contains the new promoted item:
If you still have question about Sharepoint Search then let me know by leaving a message in the comments section!