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.

One thought on “Hit Highlighting in SharePoint Search Document Titles

  1. Pingback: novolocus.com » Hit Highlighting inside Adobe PDFs using SharePoint Search

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>