Home > SharePoint, SharePoint 2010 > SharePoint 2010: Pre-filtering search results using “Append Text To Query” (AppendedQuery property)

SharePoint 2010: Pre-filtering search results using “Append Text To Query” (AppendedQuery property)


I recently needed to create a new set of search results page that pre-filter the search results.

One search results page needed to only show pages based on a specific content type.

The other search results page had to show people results that are pre-filtered based on the organisation that the user belongs to. The organisation is specified in the user’s profile with a Term Set to choose from (i.e. Managed Metadata).

Fortunately this turned out to be very straight-forward. Rather than have to rely on manipulated query strings or custom searches, both CoreResultsWebPart and PeopleCoreResultsWebPart have a property in the UI called “Append Text To Query” where you can define the filter which will always be applied to the search results in addition to using your search keywords. This is defined by entering the Managed Property name mapped to the field to filter on, followed by colon then inside double quotes enter the value to filter on. If this is a Managed Metadata value from within a Term Set, you only need to enter the term label for this to work.

Both examples for core search results and people search results can be see in the web part properties screenshots below:

Search Core Results - Append Text To Query

Search Core Results – Append Text To Query

People Search Results - Append Text To Query

People Search Results – Append Text To Query

The web parts can also be programmatically configured with the same values using the “AppendedQuery” property of the CoreResultsWebPart and PeopleCoreResultsWebPart classes.

Advertisements
  1. Amit
    December 18, 2012 at 12:48

    Thanks for this lovely post. I was stuck with out of the box seach result WP. This was great help,

  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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: