How to highlight search terms in Umbraco examine searches

I've posted a wiki page over at our umbraco that shows how to highlight search terms in Umbraco examine searches using Lucene.Net.Highlight. Source code is attached to the wiki post.

The code was lifted from an original forum post by Ismail so credit to him - I wouldn't have known where to start otherwise. Also thanks to Shannon who made a quick change in the latest version of examine to make the highlighting easier and faster to do.

Once you get the code up and running the result is quite pleasing - the highlighter will highlight terms even if you are using fuzzy terms derived from your original search text:

Examine Highlighting

I'd classify this is a 30 minute hack. I don't fully understand the inner workings of what i've put together. The code effectively does a search within a search against the query results to perform the highlighting so I am sure there are efficiency gains to be had. You can see from the screenshot above that highlighting takes longer than the original search against the text.

Comments

Leave a comment