IMHO there is a bug in your highlighter, take a look:
{% highlight "xxxxxxxxxxxxx foo bbxxxxx foo" with "foo" max_length 5
html_tag "span" %}
this will produce "xxxxx..."
Substring started from 0 is incorrect in this case because there isn't
any keyword to highlight. IMHO this should return "...foo b..."
instead - it's much better substring because it contain highlighted
key. I made a little research and found (IMHO) problem in find_window
function in utils.py:
best_start = 0
best_end = self.max_length
# here you check if context is valid
for count, start in enumerate(words_found[:-1]):
# here search for substring with the highest keywords
density
return (best_start, best_end)
If you don't find better substring you should return susbstring
started from index of
occurrence of first keyword, not from 0.
IMHO this could be fixed by adding before this line:
for count, start in enumerate(words_found[:-1]):
this code:
best_start = words_found[:-1][0]
best_end = best_start + self.max_length
IMHO that behavior is a bug and should be fixed but if I'm wrong then
sorry about # confusion & please tell where I made mistake.
regards,
Robert Gawron
Daniel
> --
>
> You received this message because you are subscribed to the Google Groups "django-haystack" group.
> To post to this group, send email to django-...@googlegroups.com.
> To unsubscribe from this group, send email to django-haysta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-haystack?hl=en.
>
>
>