Programmatically Setting the Fetched Properties to an Extended Search Core Result Web Part

May 26, 2011

This week I needed to extend the search core result web part to be able to do some custom filtering and search result styling.

For the search result styling, additional fetched properties (columns) needed to be added programmatically to the Web Part properties. But every time I checked in the web part properties, these fetched properties were not added, and I end up with the default fetched properties.

After investigating the "Microsoft.Office.Server.Search" assembly I saw that you must meet three conditions.

  1. The "SelectColumns" (Fetched Properties) string may not be Null or empty;
  2. The "PropertiesToRetrieve" must be Null or Empty;
  3. "UseLocationVisualization" must be false.

Solution

The solution to programmatically add your columns to the fetched properties is the following:

"fetchProp" is a string that contains the following content.

Comments