Home > Microsoft SharePoint, SharePoint 2013 Search, SharePoint2013 > SharePoint 2013: Content Search web part query having query variables with multiple values

SharePoint 2013: Content Search web part query having query variables with multiple values

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

TermSet

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.

User_Profile_Property

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

Search_Query

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.

Query_Transform

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: