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.

I wondered if this was a fault in the XSL I’m using, so I looked at that:

XSL for Hit Highlighting in the Title of a document

This code can be found here.

As you can see, all it does is test to see if there is a hithighlightedproperties/HHTitle element. If so, display that, otherwise use the normal title.

Therefore, I opened up a search and looked at the raw XML I got back:

Hit Highlighting properties in the Search Results XML

You can see that in this case it has picked up the terms to be highlighted in the title, and has given it a surrounding <c0>..</c0> tag. Digging on through this I found that filenames that had the search term immediately before their ‘dot-extension’ would not highlight correctly. If there was a space before the dot-extension, though, they would.

Looks like a minor buglet in SharePoint.

Advertisements
Hit Highlighting in SharePoint Search Document Titles

3 thoughts on “Hit Highlighting in SharePoint Search Document Titles

  1. Good article, considering the fact that there are not many helpful resources on the web for FAST SharePoint Search 2010. I had a quick question regd Hit Highlighting. I understand that by default the Title and Body are HitHighlighting enabled. When I was evaluating the result from FAST, I found the HitHighlightedSummary element had the hit highlighted content of the Body property. Similarly, the HitHighlightedProperties element had the hit highlighted content for the Title and I believe in addition it is possible to enable the same for Url.

    Now, in my system, I have created our own managed properties, myTitle. I’m trying to enable hit highlighting for this property. Any idea on how I could go about doing this? I’ve tried setting the Result for the property to Dynamic, however that didn’t do it. Also I do not find sufficient documentation on how this is supposed to work. If I enable Dynamic Summary for a property (say myTitle), will the hit highlighted summary become available under the HitHighlightedProperties element or the HitHighlightedSummary? Is there any helpful guidelines/documentation around this?

    Like

  2. Is this a FAST search system? I’ve never used FAST search – the above was actually about SP2007!

    To be honest, I wouldn’t mind knowing how to enable hit-highlighting for a field, but I don’t know the answer myself…

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s