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.
3 thoughts on “Hit Highlighting in SharePoint Search Document Titles”
[…] These bits are highlighted in yellow. Otherwise, we just output the link. (Note: this page doesn’t really use a lot of the neat features of your search results XML, like the hit-highlighted title). […]
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?
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…