You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
602 B
Python
18 lines
602 B
Python
# -*- coding: utf-8 -*-
|
|
from aldryn_search.base import AldrynIndexBase
|
|
from haystack import indexes
|
|
from haystack.utils.highlighting import Highlighter as _Highlighter
|
|
|
|
|
|
class SearchIndex(AldrynIndexBase):
|
|
text = indexes.NgramField(document=True, use_template=False)
|
|
|
|
|
|
class Highlighter(_Highlighter):
|
|
def render_html(self, highlight_locations=None, start_offset=None, end_offset=None):
|
|
return super(Highlighter, self).render_html(
|
|
highlight_locations=highlight_locations,
|
|
start_offset=max(0, start_offset - 20),
|
|
end_offset=end_offset + 20
|
|
)
|