Customizing SharePoint 2007 Search Result for Structured Content

The out of the box Search Core Result web part displays search result in a format that is best suited for unstructured content. With results laid out vertically highlighting content that matches the search criteria, it provides end users to quickly skimp through the result set. Though this format is best suited in scenario where the search result contains unstructured data from various content sources - SharePoint, File System, Web, and LOB - it doesn't do justice when users need to search only structured content.

While databases such as SQL Server is great for transactional structured data, SharePoint excels in collaborative structured as well as unstructured data. Before we go any further, for the purpose of this discussion, structured data is one that is stored in row and column format. It's called structured because column provides specific meaning / context to the data. Whereas, unstructured content is not represented by row and column. For example, content in Word document or a PDF document. In SharePoint you could bring structured data and unstructured content together in either a List, which allows user to capture metadata along with attachments; or a document library, which allows user to maintain documents along with metadata. This combination of metadata and documents is what brings structured data and unstructured content together in SharePoint. This post is not about structured and unstructured content, but wanted to provide a context on need for displaying search result in tabulat format.

More often than not, enterprises would use some form of List to manage content specific to a purpose (for e.g. knowledge repository). Metadata management is best achieved by using Site Columns and Site Content Types. Based on my experience when user searches within a list, they would like to see results laid out in tabular format, arranged in rows and columns, rather than the out of the box search result format. There are many good blog posts that explains usage of SPGrid and some form of coding to display search result in form of DataGrid. While SPGrid provides rich features such as filtering and context menu, it also requires effort for coding, testing and deployment. If your objective is to just display the results in tabular format with metadata as columns and results arranged in rows, then you could get away by simply changing the Search Core Result XSLT.

Lets consider we have a knowledge repository in SharePoint. This repository is in form of List that is mapped to a Site Content Type named KnowledgeBase. KnowledgeBase has 4 site columns: Title, Knowledge Author, Group and Summary. One of the items in this repository is title MOSS Global deployment, with "Knowledge Author" as "John Doe", Group as "Manufacturing" and some text in the Summary column. Without any kind of XSLT customization, when user searches on this list for "MOSS Global", they will see result in format below

Sharepoint OOB Search Result

After we customize the search result XSLT the result format will look like this:

Customized Search Result in Tabular format

Note that the Title is hyperlink pointing to the url of the content. Since we are using the same web part, all other web parts such as Search Actions, Search Summary and Search Paging will work as usual without any change. What we have done is simply changed the XSLT.

Before we change the XSLT, we will need to define the metadata as managed properties. We will create following managed property:

  1. KAuthor: Mapped to Knowledge Author column
  2. KSummary: Mapped to Summary column
  3. KGroup: Mapped to Group column

We don't need to define Title and Last Modified as they are already defined in SharePoint.

In order to include newly created managed properties in XSLT, they need to be included in the "Selected Columns" property of the Search Core Result Web Part.

Modify the Search Core Result Web Part by clicking on the "Edit" link. Expand the "Results / Query Options" section. Include KAuthor, KSummary and KGroup in the "Selected Columns" as shown below.

<root xmlns:xsi="">


<Column Name="KGroup"/>

<Column Name="KAuthor"/>

<Column Name="KSummary"/>    <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"/>     



It is important to understand the XML returned by the Sharepoint Search engine. The XML returned has all the columns defined in "Selected Columns" property of the web part. The XML looks like this:

        <kauthor>John Doe</kauthor>    
        <ksummary>This knowledge article outlines challanges and best practice recommendation on implementation of Sharepoint on global platform.</ksummary>    
        <title>MOSS Global Deployment</title>    
        <author>System Account</author>    
        <hithighlightedsummary> <ddd />  of Sharepoint on <c1>global</c1> platform. <ddd /> <c0>MOSS</c0> <c1>Global</c1> Deployment  <ddd /> <c0>MOSS</c0> <c1>Global</c1> Deployment </hithighlightedsummary>   
         <hithighlightedproperties>       <HHTitle>         <c0>MOSS</c0> <c1>Global</c1> Deployment</HHTitle>                   <HHUrl>
http://myportal-18e67cd/sites/Knowledge/Lists/KnowledgeArticles/DispForm.aspx?ID=1</HHUrl>             </hithighlightedproperties>   
         <imageurl imageurldescription="Result of type: document">/_layouts/images/STS_ListItem16.gif</imageurl> 

Now that we have done the ground work, next we modify the Search Core Result XSLT. Following link has the XSLT to display results in tabular format.




Modified Search Core Result XSLT

Open the XSLT in XSLT editor such as Visual Studio.NET 2008. Line 126 to Line 133 contains XSLT processing for displaying the column header. You could add your own columns here. Line 149 to Line 168 contains processing for displaying search result in table. You could replace managed properties shown here with your own managed properties. You could include any of the other XML elements from XML returned from Search.



Comments (10)

  1. Eric Mulder says:

    Great Article!

    I have done this for a client as well. I created the XSLT to make the results look like a document library view. In this same view i also want to add an edit link so people can easily edit metadata for the document. The link goed to EditForm.aspx?ID= …. i have used the workid column for this. This works for some documents, however.. most of the documents give an error that the specified document does not exist or has been moved.

    Comparing the workid in the searchresults to the ID shown in the edit url within the document library view gives me 2 different ID’s.

    Any clue?

  2. Arbindo says:


    Thanks for the note.

    For the Edit link, I created a managed property that mapped to ID crawled property and used the new managed property in the Edit URL. Let me know if you need further detail.


  3. Rens says:

    I’m also working on the "edit url" link, only problem i’m facing at the moment, is how to get the library name of the document as a managed property in the search results. I need this name as it is a part of the url i’m dynamically building.

    Any ideas someone?

  4. Garry Trinder says:


    Not sure if there is a managed property for the library name, but if you have a custom content type, you could use the contenttype managed property to identify content in the search result.


  5. Baly says:

    The issue after customizing search resutls using Sharepoint designer in this way is that it doesn’t highlight the search keyword in the results…

    Can we resolve this ??

  6. Garry Trinder says:


    You could certainly include search term highlighting in this approach. You just need to include the xsl template HitHighlighting in your customized xsl and call HitHighlighting template with relevant parameters.

    HitHighlighting template and its usage can be found in the xsl of searchcoreresult webpart.


  7. Jamie says:

    I am having the same problem as Rens, can you be a little more descriptive as to how you implemented your edit link…

  8. remandlo says:

    I’m glad I can now disply my mapped properties in the search core results webpart  but the problem I’m having is that my results are displayed in one line after the Metadata field line.

    ie. item1 item2 item3  …. item(n)

    Has anyone experienced this?


  9. Pritam says:

    Do you know how to add sorting to the tabular search results? The sorting should work across the entire result set and not the paged result set

  10. jstark says:

    Great Article and a long time ago. Does anyone have a link that works for the XSLT? Link below does not work. 🙁

    Modified Search Core Result XSLT

Skip to main content