Create a User Intent Query Rule

One of the best new features of SharePoint, in my opinion, is the Query Rule. If you haven’t seen one of my search sessions where I talk about Query Rules, you should come to Las Vegas for Dev Intersections. I’ll be presenting a brand new session devoted to just that, Query Rules. (Well, to be completely honest, it’s Query Rules and Display Templates…because they go together like peas and carrots, Bogart and Bergman … you get the idea.) In this post I’ll detail how you can create a Query Rule that acts on a user’s “intent”.

What is User Intent?

What I mean by “intent” is the idea that a user wants to search for some kind of content and they want to do it in a natural way. For example, when I am talking to other speakers about a PowerPoint file from a session we tend to call it a “deck”. (I know, I know, you don’t know what a deck is…well, back in the days when music came from round black vinyl disks that we played on a big box called a record player, slide shows were projected by an actual carousel slide projector from a stack of slides, the stack was called a deck, as in deck of cards…if you don’t know what a deck of cards is, well, now you have two reasons to come to Vegas!)

Try this, perform a search for content that returns PowerPoint files. Now add the word “deck” to the end of your search. What you should see is the results from the default (out of the box) query rule for PowerPoint files. This is one example of the out of the box intent rules that ship with SharePoint 2013.

SharePoint Deck Rule

What you are seeing is a result block where the query rule is detecting the word “deck” and then creating a new query that does a better job of filtering search results. In this case the rule removes the Action Word “deck” and effectively changes the query to “PowerPoint files that contain the word SharePoint”.

How can I use Intent?

How you decide to use intent is based on many factors that are specific to your users, your business, and the language you use in “your world”. (Think “TPS Report”, as a viewer of Office Space you never really know what a TPS Report IS, but everyone at Initech does, it is part of the company process, culture, and jargon.)

In this sample I’ll create a rule to help our users discover videos created by our marketing department. The marketing folks call their videos “flicks” and want the users to adopt the terminology. In seeking to help marketing we’re going to create a Query Rule that makes “flick” an action term and enhances the users query.

Step by Step

For my scenario I am using SharePoint 2013 Enterprise. I have uploaded my videos to an Asset Library called Videos. The Asset Library is helpful in this case as it supports the Image, Audio, Video and Video Rendition content types.

  1. Begin by testing your search query. In my case if I search for “Ruby” and choose the Video Result Type Refiner I get 4 results. Video Refinement

  2. If I search for “Ruby Flick” I get no results. Test Flick Rule

  3. Create a new Query Rule by clicking Site Settings | Search Query Rules.

  4. Select a Result Source, in my case my results are in the Local SharePoint Results Result Source.

  5. Click New Query Rule.

  6. Provide a Rule name like “Video Intent”.

  7. Change the Query Condition to Query Contains Action Term. Enter the word “flick” in the text box. Query Condition

  8. Next we are going to define a Result Block for our rule. Result blocks are a very cool feature that I will write about later, I promise, for now though, Click Add Result Block.

  9. In the Add Result Block dialog notice the Query Variables that you have to work with. The rule extracts our Action Term making the rest of the query available to us as “subjectTerms”. All we need to do is create the query. Begin by changing the block title to Video Results for “{subjectTerms}”.

  10. Now you have to decide on your Query. The version of SharePoint Server will influence your decision. For this specific demo, SharePoint 2013 Enterprise has a predefined Result Source for Local Video Results. I can choose that for the Search this Source and choose 3 for the number of Items to show and I am done.

Query builder

If you don’t have Enterprise, or you need more control over the query, you can click the Launch Query Builder button and formulate a more specific query. For example you could use the query: "{subjectTerms} ContentType:Video"

Query Builder

  1. Click on the Test tab to test your query on a few different folks. You should see Relevant Results for your target content. Query results

  2. Once you are satisfied with your results click OK to close the Query Builder and return to the Rule Editor. Change the number of items to your desired display value (I chose 3).

  3. Finally open the Settings section and locate the radio button pair that controls where the result block will show. For the demo I always choose This block is always shown above core results, but you should consider the other option. This is an amazing concept. Rather than always showing on top, the alternative is to let the results “float” in relevance order with the rest of the results. That means that your result block may wind up on another page of results (or not at all) but the key concept here is they will show only if they are relevant to the users query!

  4. The last setting I’ll change is the Item Display Template. I like to change this to Video. It may seem obvious, but this setting enables you to specify how the results are presented, even selecting your own custom Display Template if you like. Assign the display template

  5. Click OK to close the dialog and click Save to create your rule.

  6. Return to your search page and test your work. In my case I enter the query “Ruby Flick” and I see the results I expect, 3 videos with a reference to Ruby. Video results

Help your Users!

I think the concept of user intent is a very cool one. I have used it in several instances where our query logs have demonstrated that users are attempting to find content using “natural language” and the search results have been less than satisfactory. How are your users attempting to find content? Are they looking for customers by using the term “client” or “customer”? If so you can add a result block to aid them in finding what they seek!

|| Display Templates || Query Rules || Search || SharePoint 2013

comments powered by Disqus

Let's Get In Touch!

Ready to start your next project with us? That’s great! Give us a call or send us an email and we will get back to you as soon as possible!