Saturday, August 9, 2014

S15E08–Query Rules – I am Trigger Happy (intent)

Want the book? Go get it!

This is the eight episode in the series “SharePoint Search Queries Explained - The Series”. See the intro post for links to all episodes.

In this fourth episode around query rules, I am going to focus on capturing the intent of the user. What is the person searching really looking for? If you look at a random query log you can, more often than not, easily pick out queries which you could call “Q and A queries”. By “Q and A query” I mean a query which is meant to bring back an answer which you can take action on right away.
Some examples:

Question (query) Answer (result)
sales report oslo List sales reports for oslo, with newest on top
pain killers Where can I locate pain killers in the office
company presentation The most up to date company PowerPoint presentation
developer blog posts Blog posts about development
mikael svenson Information about me :-)

The common denominator for all of the above queries is that the terms themselves can be used to rewrite the query to provide better results for the end-user. If you don’t turn business rules into query rules, the top 10 results on your page will likely not have the answer to all of these questions.

I have already touched on some ways to do this in Get things in order and Rewrite and  paraphrase, but I will give sample solutions to the five samples above.

Query: sales report oslo

For this one I will create a rule which trigger on sales report and limits the results to only sales reports. I also order the results with the last modified ones on top, as the user is more likely to want fresher content.
image

Make a note of the {subjectTerms} variable which contains all query words except the trigger term. This means the final query would be:

oslo SPContentType:SalesReport

In the above query rule I have also ordered the results on LastModifiedTime in descending order.
Another possibility is to create a result source for sales reports, and display the results in a result block instead of changing the main results.

Query: pain killers

This query is a typical example of a best bet, or promoted result. There might be a document or a page with the information you need, but a best bet is much better suited for this scenario.

image

Query: company presentation

This is similar to sales report. One way is to trigger on both terms and list presentations by content type or location. Another is to trigger on only presentation limiting the results to PowerPoint files hoping the term company in itself will bring to the top what you want. Or, create a best bet. It all depends on your data and how you best can present the answer.

Query: developer blog posts

For this one I will trigger on blog posts. I will then boost posts which have been tagged with developer, promoting them to the top of the result list.
image
{subjectTerms} contentclass:STS_ListItem_Posts {?XRANK (cb=1) owstaxIdTaxKeyword:"{subjectTerms}"}
It’s also possible to display a result block instead of changing the main results.

Query: mikael svenson

This one is easy by default as SharePoint provides a rule to match the names of people in your organization, and displays them in a result block.
image
You could however build this out to trigger on a list of only first names or only last names as well. To do this you have to get the list of names into a dictionary in the term store. If you are on-premises you could map first and last named fields from the User Profiles to custom term sets for this purpose. For SharePoint Online this is not possible and you would need to run code from the outside to create these dictionaries automatically.

Summary

Matching the intent of your users is a matter of understanding their queries, and change them to return what the user is actually looking for. Two good starting points are the search query logs and your own domain knowledge of your business!

Happy triggering!

References: