CODEDIGEST
Home » Articles
Search
 

Technologies
 

Sponsored links
 

CodeDigest Navigation
 

Technology News
No News Feeds available at this time.
 

Community News
No News Feeds available at this time.
 
Search Results in SharePoint

By Sveta Yerpilev
Posted On Mar 15,2009
Article Rating:
Be first to rate
this article.
No of Comments: 0
Category: SharePoint
Print this article.

Search Results in SharePoint

By Sveta Yerpilev - SharePoint Consultant

KWizCom Professional Services – www.kwizcom.com

 

Summary

Part 3 of 3 part SharePoint Search Customization series by Sveta Yerpilev.

Sveta gives a clear overview of SharePoint search and how to create the results you want.

A client of mine once requested that I change the look and feel of their search results page. The client was a large company that had decided to change the design of their SharePoint portal. The portal had a search center which was where I needed to make the change.

 

This is how I did it:

 

First of all I needed a Core Results Web Part. You can add a web part to your results page from the Web Parts Gallery or use the SharePoint web part that is automatically added to each search results page.

 

Next I had to setup the fields (columns) I wanted to see in the search result. To do so - open the properties of the Core results web part and under the Results Query Options change the Selected Columns xml text. To add a new column you need add this text to the xml before </Columns> tag:

 

 <Column Name="YourColumnName"/>

 

Save the changes and now you can start to redesign the look and feel of the search results. The fastest way to do this is to use the XML of the search results. To access the XML you need to add this code instead of the XSLT code of the web part in the XSL Editor:

 

<?xml version="1.0" encoding="UTF-8"?>

   <xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">

<xsl:copy-of select="*"/>

</xsl:template>

</xsl:stylesheet>

 

 

 Save your changes and do a test search. You will get an XML code of the search results. Copy this code and paste it to notepad. Save the file on your desktop and open SharePoint Designer. Connect to one of your SharePoint sites and create a new blank ASPX page. After this go in to the design mode of your page and add a new DataView Web Part. In the Data Source details choose the XML files and add a new XML file. In the new opened window browse to the file you saved before and import it to SharePoint Designer.

 

Once you perform this operation you'll see your file in the XML files section.  Click on this file and press "Show Data".




Now you will be able to design your Data View Web Part however you want, using columns from the Search Results XML file. You will also be able to perform sorting/filtering/grouping on your search results but keep in mind that each function will create results only on the page you are currently using. In other words, if you sort your search results by site title the grouping will group the content of your current search results page.

 

After you finish designing your page you the only thing left you need to do is copy the entire  code from your page, between the tags <XSL> and </XSL>, and paste it to the XSL Editor of the Core Results Web Part. Save your changes and verify that everything works by doing a test search. If you like the look of your search results page you can delete the temp ASPX page from your SharePoint site and delete the search results XML file.

 

If you would like more information on customizing a search results page I suggest this insightful article by Tobias Zimmergren:

http://www.zimmergren.net/archive/2008/03/15/moss-2007-customize-the-search-result-using-xslt-part-3-customize-using-sharepoint-designer-2007.aspx

 

SharePoint gives you many options for customizing your search results.

 

You can define different search results pages for each search scope you run.

 

You can set a specific search results page on the server level and redirect all search results to that page.

 

You can even define a search results page for a Search Box Web Part - it will redirect all search results (not including the Contextual Search Scope Search results) to the page you defined.

 

If you create a new Search Center you may want to redirect all search queries to the Search Center search results page.

You can setup this function on the scopes level or in the Search Settings of the root site in your Site Collection.

 

I hope this article (and the first two parts of this series) on SharePoint search results has been helpful to you. Please continue to visit the KWizCom blog for more helpful information, SharePoint tips and "how to" guides. We are here to help!

Similar Articles