[Django]-Showing more of the highlighted context

4๐Ÿ‘

โœ…

I think the best approach would be to extend Highlighter as described in the docs.

Something like:

from haystack.utils import Highlighter

class ShowMoreTextHighlighter(Highlighter):
    def find_window(self, highlight_locations):
        their_start, their_end = super(ShowMoreTextHighlighter, self).find_window(highlight_locations)
        # perform some clever operations here to find an earlier start location
        my_start = their_start/2 # or just do something simple
        return (my_start, their_end)
๐Ÿ‘คHamms

Leave a comment