User Centric Query Rules

In SharePoint 2010 anytime a client asked for a query that user User Profile properties to drive the results we had to develop and deploy a custom search solution. In SharePoint 2013 we can now access User Profile properties through the much improved Keyword Query Language. I use one simple example of this in my Search Session demos. I call it “Your Documents”.

Your Documents Query Rule

  1. Create a new Query Rule on Local SharePoint Results.
  2. Give the new rule a name.
  3. Remove the Query Condition, this rule will fire on all queries.
  4. Click Add Result Block and formulate your query as follows:
    1. Block Title – Your Documents for “{subjectTerms}”
    2. Query - {subjectTerms} Author:{User.Name} IsDocument=1 This query says, give me only documents containing my subjectTerms where the Author property contains the current user’s name.
      • Click OK.
      • Click Save.
      • Return to your search center and try a query using a word contained in a document you authored. You should see something like this:

Query Rules in results

Using Other Profile Properties

I work with many clients who use SharePoint for Knowledge Management. Many of them create a Knowledgebase or FAQs and the like. A common request is to create a Query Rule for hits on the FAQ articles in hope that it will efficiently solve issues for the users. Here is the result of a simple query rule that shows a FAQ hit on the term “password”.

FAQ Results

The thing that is special about this FAQ is that some of the articles are tagged by the location to which they apply. Notice that I got two hits for “password” because the process for changing your password in Austin is different from San Antonio. What I would like is only one hit based on the location of the user who issued the query.

The FAQ List

With query rules this is easy.

  1. Create a new Query Rule on Local SharePoint Results.

  2. Give the new rule a name.

  3. Remove the Query Condition, this rule will fire on all queries.

  4. Click Add Result Block and formulate your query as follows:

    1. Block Title – FAQ Results for “{subjectTerms}” that apply to your office
    2. Query – {subjectTerms} {Location:User.Office} Path:http://intranet.doghousetoys.com/IT/Lists/FAQ contentclass=STS_ListItem_genericlist

    This query says, give me only list items from the FAQ list containing my subjectTerms where the Location property contains the current user’s office. (Note: I included the path and contentclass in the sample for completeness, ordinarily I would create a result source for the FAQ to make life easier.)

    • Update: It occurred to me that some folks might want to use the term store and the Office Location property, you can do that too. Change the query to “{subjectTerms} owsTaxIdLocation:{User.SPS-Location}”

    • Click OK.

    • Click Save.

    • Return to your search center and retry the query. Ruby is in the Austin office, so her results for “password” are now specific to her.

Results targeted to the user

Finally…

I am amazed, over and over, at what we can do with these powerful features of Query Rules. Try this out and see how it works for you!

|| 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!

+1.512.539.0322