5. Customizing Search Results Metadata
It is often necessary to change or remove the
metadata returned with search results. For example, an organization
might want to change or remove the property Author and replace it with
Department on their Internet-facing Search Center site. This could be
especially important when information about individual corporate
employees should not be searchable metadata.
Note:
In this example, you should assume that the metadata
exists for Department and that a managed property has been created and
associated with the metadata.
It is not necessary to delete or modify the managed
property being displayed if all you need is to remove it or replace it
with another managed property. To change the managed properties
retrieved by the Core Results Web Part, use the following steps.
Open the search results page in edit mode.
Select Edit Web Part for the Search Core Results Web Part.
Expand the Display Properties section as shown in Figure 13-37 above.
Clear
the Use Location Visualization check box so the Web Part will use your
customizations instead of the configuration of the Federated Location
Definition at the search application level.
Copy
the entire XML string contained in the Fetched Properties text box into
your favorite XML editor. This string defines much of the functionality
of the Web Part. These managed properties are sent to the query manager
as managed properties to be retrieved for each search result in the result set. The Fetched Properties code in the Core Results and Search Action Links Web Parts is as follows.
<Columns>
<Column Name="WorkId" />
<Column Name="Rank" />
<Column Name="Title" />
<Column Name="Author" />
<Column Name="Size" />
<Column Name="Path" />
<Column Name="Description" />
<Column Name="Write" />
<Column Name="SiteName" />
<Column Name="CollapsingStatus" />
<Column Name="HitHighlightedSummary" />
<Column Name="HitHighlightedProperties" />
<Column Name="ContentClass" />
<Column Name="IsDocument" />
<Column Name="PictureThumbnailURL" />
<Column Name="PopularSocialTags" />
<Column Name="PictureWidth" />
<Column Name="PictureHeight" />
<Column Name="DatePictureTaken" />
<Column Name="ServerRedirectedURL" />
</Columns>
Locate the managed property and remove it from the string. In the example above, you will remove <Column Name=“Author” />.
Add the managed property that will replace Author. For the example above, you would add <Column Name=“Department” />.
Replace the default Fetched Properties code with your modified code.
After
you add managed properties to this list, you must also modify the XSL
to specify how the new property is to be displayed. There are two
options for modifying the style sheet for the Web Part. In this section,
you can click the XSL Editor button to expose the XSL code within the
Web Part. You will probably find it easier to copy the code into your
favorite editor for modification and then paste the modified code back
into the editor to save it. In the Miscellaneous section, you can enter
the URL for an external style sheet used by one or more Web Parts.
Test the new search criteria.