New Toy: SharePoint Search Server Express 2008 – Let’s break it!
In this article we’ll take a shallow look at how to customize the search results by finding the Search Core Results web part editing its output XSLT a bit. Yes, Microsoft Search Server 2008 Express has been out for quite some time, but I’ve just now started playing with it in order to work on some VizitSP items I have for our upcoming releases.
There’s a lot of information out on the web covering these topics; I’m certainly not the first, but I like having the reference for personal use later if I ever have to return to the topic.
Search Core Results – How to edit the search output
A little poking around with web parts and you’ll know right where to go. Begin by running a simple search:
We’ve all seen this friendly, innocuous search box, so use it! I have one item in two crawled lists on my SharePoint installation, so I search for it by name and get the standard result:
Click on the Site Actions button in the upper-right of the search results page and select Edit Page:
You’re then presented with the page editor that will show you all of the web parts that exist on the search results page:
Now, in order to edit the results click the down arrow on the upper-right corner of the Search Core Results webpart. This will add another frame to the view on the right edge of the page with Search Core Results Options. Click the Modify Shared Web Part link to get to the guts of how this webpart is displayed:
Now the fun begins. To start off, click in the XSL Editor window, hit ctrl-a and ctrl-c to copy everything in there, then paste it into a window that’s reasonable to work with. In some browsers, that editor window is resizable, but it’s still ridiculous to work in.
MSDN has a great article that explains all the workings of the search results XSLT. Generally speaking, though, you’ll probably concentrate on the area at or around line 130 that is the template responsible for showing the results: <xsl:template match="Result">
To see what XML you’re transforming with this XSLT, check out this article, also on MSDN on how to display the result XML.
A quick an easy way to see the results of an edit would be to go to the c0 template, which matches on the first search term of a search. Normally this template simply bolds the search term in the results:
but by simply replacing the bold tags with a span tag and some style, you can get highlighting:
And the results:
We’ve just splashed the surface into search, but there’s obviously a lot that wasn’t looked at, like adding custom webparts to this page. Codeplex has a project, Faceted Search, that is a good example of how far you can go with it.
Until next time!