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”.
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”.
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.
With query rules this is easy.
Create a new Query Rule on Local SharePoint Results.
Give the new rule a name.
Remove the Query Condition, this rule will fire on all queries.
Click Add Result Block and formulate your query as follows:
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.
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!
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