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’:
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:
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:
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.