What happened to Best Bets? Introducing Query Rules
Audience: Search Admin/ITPro
Pre-requisite: This blog assumes the reader has basic SharePoint 2010 Search Administration knowledge.
If you’ve ever managed Search on SharePoint 2010 Products, chances are you’ve created Search Keywords and Best Bets. They are perhaps the easiest way to improve relevance on specific queries by letting you promote results to the top of the page, in whatever order you want. But in SharePoint 2013 Preview, you will not find the Manage Search Keywords link in Site Settings.
This is because Search Keywords have grown into something much more flexible: Query Rules. Here’s the difference.
- Search Keywords say “when the query is ‘image library’, promote a link to our image library.”
- Query Rules say “when it looks like the user wants images, show useful image results. ”
The power of Query Rules is this generality. Instead of just matching specific queries, they let you infer what the user wants; instead of just promoting specific results, they can show whole other blocks of results relevant to the user’s query.
A Search Keyword works for the exact query 'image library' or 'picture library', while a Query Rule can improve search for a whole lot of different image queries.
Yet if all you want to do is promote results to the top for a query — worry not! It’s as easy with Query Rules as it was with Search Keywords. In fact, if you’re upgrading from SharePoint 2010 Products, SharePoint 2013 Preview transforms all your old Search Keywords into Query Rules for you.
So let’s create a Query Rule that fires on the exact query ‘image library’ or ‘picture library’, then promotes a result for the Image Library to the top of the page.
First, we’ll go to the Query Rules management page. On your search center’s upper-right-hand corner, click the gear icon, then select Site Settings.
Next, on the Site Settings page, under the Search heading, click Query Rules. Note that you may see a Search Query Rules link under Site Collection Administration. This happens if you’re the Site Collection administrator and the search center is the site collection’s root site. Don’t click that one; those Query Rules affect every site in the site collection, and for now we want to focus only on the search center site.
Now that you’re on the Query Rules page, the first question to ask is “Where will the user be?” For example, do you want to manage Query Rules for your main Enterprise Search? Or for People Search? Or Video Search? Each search experience, out-of-the-box or custom, can have its own Query Rules.
This is what we call the query’s context. You configure Query Rules for a particular context by using that first row of dropdowns in the Query Rules management page.
To manage Query Rules for a specific search experience, use the first dropdown to pick the Result Source for that experience. We’ll go into Result Sources in another post — for now, think of them as a SharePoint 2010 Federated Location plus a Search Scope. Each search experience sends queries to a Result Source, and that source guarantees results meeting certain conditions. For instance, People Search sends queries to the Local People Results source, which only returns People results.
We want our new Query Rule to fire on the main Enterprise Search. That search experience sends queries to the Local SharePoint Results source (which includes everything SharePoint crawls except People). So choose Local SharePoint Results from the first dropdown.
Next, click Add Rule to start creating your new rule.
Having picked a context, we just need to give the rule a name, then specify its conditions and actions. In other words, say when this rule will fire, and what it will do when it does. This is very similar to creating a Search Keyword in SharePoint 2010:
Give the rule a name: Image Library.
In the Query Conditions section, leave the condition type on “Query Matches Keyword Exactly”. In the textbox, type the queries we want to match, separated by semicolons: image library; picture library.
In the Actions section, since we want to promote a result to the top of the page, click Add Promoted Result. These are just like Best Bets in SharePoint 2010.
In the Add Promoted Result dialog, fill out the title, URL, and description.
Click Save in the dialog, then Save in the Add Query Rule page.
And that’s it…you’ve created a Query Rule! To try it out, go to your search center and search for ‘image library’ or ‘picture library’ (note that it can take a few seconds for the Query Rule to start working).
This Query Rule, while simple, demonstrates the high-level steps for creating all Query Rules.
- Pick the context (e.g., queries sent to the Local SharePoint Results source).
- Specify the conditions (e.g., fire if the query exactly matches ‘image library’ or ‘picture library’).
- Specify the actions (e.g., promote a result for the Image Library).
In our next Query Rules blog post, we’ll play with some more interesting conditions and show you a new kind of action: Result Blocks.