Archive for the 'Search' Category

The curious incident of the date column in the night-time

I have been tearing my hair out over a problem with dates and timezones. We have a site column ‘Document Date’ that we are using in our search results page. It only holds a date.

Our client noticed that some dates appeared on the search results page as a day earlier than the value in the lists themselves. For example, the list would show a document date of the 8th of May, but the search results would show the 7th of May. Curious, and the start of a bit of a detective story… Read more »

Hit Highlighting in SharePoint Search Document Titles

I came across an interesting behaviour in a search results page I’ve been working on. I’d added some code to do search highlighting on the results of a query. Here’s an example of the results I got for a search for ‘Barnacles’:

Search Results showing Hit Highlighting in the Titles and Description of documents

The observant amongst you will notice that the titles all contain the word ‘Barnacles’, but only some are highlighted - specifically where the word barnacles is not the last word before the dot-extension of the file name. I did some further testing and found that the search does recognise the word ‘Barnacles’ in the file name, but the hit highlighting doesn’t seem to. Read more »

Hit Highlighting inside Adobe PDFs using SharePoint Search

So, I’ve posting about some work I’ve been doing with SharePoint Search. Now, to pull it all together - I’ve been trying to do hit highlighting inside Adobe Reader, so if a user clicks on a search result Adobe Reader opens and automatically searches for occurances of the search term. Doing this requires knowing your file extension (so you only process PDFs this way), knowing the query string parameter for what is being searched for, and that you can pass parameters into Acrobat Reader. I’m not going to go too much into that last part, but you can find documentation about this on Adobe’s website (pdf). Read more »

Using a Query String parameter in the Search Results Web Part

Further work on fixing a colleague’s code. Like some of the posts I’ve found, he seems to have thought that to get the query string parameter he’d have to use Javascript - something like this. However, I found myself thinking of the Data View web part - it allows parameters based on the query string. Most people know about that. What I found, and what I think some folks don’t realise, is that the Search Core Results Web Part allows you to have query string parameters too… Read more »

What columns can I use in my Search Results?

In a previous post I described adding the FileExtension column to the XML you get back from a SharePoint search, so that you can use it in your results page. This raises the question - what columns are available for use in the Selected Columns setting on the Core Search Web Part?

Well, these columns are Managed Properties, and they’re configured on the Shared Service Provider (SSP)… Read more »

How do I get the File Extension in my Search Results?

Following on from my previous post, I’ve been looking some more at the code that one of my colleagues has created for styling up some search results. In it he needs the file extension for the item resulting, and he does this by, um, assuming that it’s the last 3 letters of the items URL. Yes, I am not amused. For example, if you look at the results from my last post… Read more »

How do I get the XML of my search results?

So I’ve just started customising SharePoint Search results for the first time. It’s an area that I’ve never really touched before, to be honest - I’ve set up the crawling, and that’s the limit. Now I find myself reverse engineering a colleagues code in order to fix it.

Well, from what I can fathom, SharePoint search results actually come from the Search.asmx webservice in the _vti_bin of your site. The results are actually returned as XML, and in the web parts (not sure which ones, but certainly the Search Core Results web part) you then render this XML to HTML via XSLT. (If that means nothing to you, I’m afraid you’ll have to look it up. That concept is a whole can of worms. Maybe even a crate of worms. Anyway…)

An obvious question is, what does that source XML look like. Well, it’s whatever you get back from the web service, and there are various ways of find that, but I found a neat little solution on a post from Tobias Zimmergren’s blog (in fact, it’s an interesting looking series for a search rookie like myself - I think I’ll have to read that). I’ll blatantly plagiarise that in a bit. Basically, his idea was to define some XSLT that just emits the XML unaltered, and then look at what you’re getting back from the search service on the search results page.

So, to test, I copied the normal search results page (mine was in a search center) to give myself somewhere isolated to test in. I went to it - and it was all empty. Not surprising - there were no web parts. I added a Search Core Results web part:

Adding a Search Core Results Web Part

You might want to add a Search Box web part to give yourself somewhere to enter your search terms, though I’m a bit of a geek and was typing directly into the URL of the browser. For example,
?k=barnacles
will search for documents about, um, barnacles.

Results Page with Search Box and Core Results Web parts

Fine. Now we need to apply the XSLT. Edit the Search Core Results Web Part:

Editing the Web Part

and edit the XSL:

The XSL Editor

Blatant Plagiarism alert - Tobias’ XSL was just:

<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=”/”>
<xmp><xsl:copy-of select=”*”/></xmp>
</xsl:template>
</xsl:stylesheet>

Note: Don’t just copy the above text - use this link. Wordpress has changed the speechmarks in the code above, and it won’t work.

Apply it and voila - XML:

The Search Results page showing XML

Now I can get on with Styling it.

Changing the SmallSearchInputBox delegate control

A colleague of mine was wanting to make some changes to the SmallSearchInputBox delegate control in SharePoint 2007. That’s the control that appears on most pages, looking like:

SmallSearchInputBox

This control is a ‘Delegate control’ - that is, you can create features to override the currently used control. What my colleague wanted to do was not display the ‘Scope’ drop down list, the Advanced Search link, and to include prompt text (something like ‘Enter Search…’). A quick dig into the FEATURES folder in 12 Hive showed that the control had a number of properties.

(The features that this information applies to are the OSearchBasicFeature and OSearchEnhancedFeature. Both contain files called ‘SearchArea.xml’, and that contains the code below. I found the folders with this in:

%12 Hive%\Template\Features\OSearchBasicFeature

%12 Hive%\Template\Features\OSearchEnhancedFeature )

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="25"
ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" ControlAssembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<Property Name="GoImageUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageUrlRTL">/_layouts/images/goRTL.gif</Property>
<Property Name="GoImageActiveUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageActiveUrlRTL">/_layouts/images/goRTL.gif</Property>
<Property Name="UseSiteDefaults">true</Property>
<Property Name="FrameType">None</Property>
<Property Name="ShowAdvancedSearch">true</Property>
</Control>
</Elements>

This shows a property ShowAdvancedSearch which sounded pretty promising for turning off the Advanced Search link. We decided to see what other properties were available, and found a good article by Clint Cherry about the SmallSearchInputBox control, and the MSDN docs. The Property tags in the XML for the delegate control set the properties of the web control class - e.g. GoImageUrl matches the GoImageUrl property on the class. Much to our pleasure, we found the QueryPromptString displays text in the search control which vanishes when it receives focus, and the DropDownMode property allows us to turn off the scope dropdown list. Hurrah!

For the values that you can set the drop down mode to, see the MSDN docs again

Installing WSS Search - Account names must be of the format [Domain\User]

Just [user] doesn’t cut it!

I was installing a MOSS system yesterday, and starting the WSS search service was causing me problems. I kept getting errors of the form

SearchServiceInstance.Provision (server ‘VM-AWB-MOSS01′) failed. Setting back to previous status ‘Disabled’.

Well, a google trawl turned up a fairly obvious solution - which just didn’t occur to me. Make sure the account name includes the domain!

Thanks Bergen!

If search isn’t indexing your SharePoint sites, try fully qualifying your domain name.

I don’t know why this wasn’t working, but search on my SharePoint VM wasn’t indexing the collaboration portal that was our top level site collection - indeed, it wasn’t even crawling it. So I changed the start path to the fully qualified path (e.g. http://vm-moss07/ to http://vm-moss07.dev.deltascheme.com/), and now at least a few pages were crawled - those being, unfortunately, the pages that redirected to the ‘not fully qualified’ path. So I put both into the content source - and it crawled the whole site collection correctly.

I’m really not sure why, to be honest. I haven’t checked the alternative access mappings, but I don’t see why the search didn’t work without the fully qualified server name. The crawling of the My Sites and Central Admin site collections worked fine without being fully qualified.

I’m sure it’s something simple - any guesses anyone?

« Previous PageNext Page »