Wednesday, March 9, 2016

Sitecore Lucene getBestFragment returning null with search results highlighting

I have been using the getBestFragment method of the highlighter class available through the Lucene contirb library - to highlight the search term(s) on the search results page. It worked as expected in most cases, however I noticed that some results were returning as null. After looking through the documentation, I found out that:
Returns: highlighted text fragment or null if no terms found
So it is important to have handling in your code and not just expect that there will be an output from this method.

No comments:

Post a Comment