Query Variables with Multiple values in Web part Query

Hi Friends,

While working with one of the SharePoint 2013 content search web part, I came across a query where query variables may return multiple values which causing my search query to fail, after struggling a lot I found a good TechNet article which solved my issue. Putting the solution here so that it will help someone from developer community.

For demo purpose I have created a Term set like following



I have a user profile property (MyProfileProperty) which is bound to above term set. I have selected the profile property values for current logged in user.



I have created a site column (MyTaxonomyColumn) which is bound to same term set and added that column in a list. After adding some entries in that list, I did a full crawl so that a managed property for the column will be created (owstaxIdMyTaxonomyColumn).

My requirement is to get all records from list having values from user profile property ‘MyProfileProperty’.

I have added a query like {|owstaxIdMyTaxonomyColumn:{User.MyProfileProperty}}



This query gets transformed as following and worked for me as the above query syntax combines all the query variable values will be combined by using the bitwise OR operation.


Ebook Download
View all
Learn
View all