forum: workaround for building index

This commit is contained in:
Antoine Bartuccio 2018-12-07 13:54:40 +01:00 committed by Skia
parent 347caa3b6a
commit 545671bec3

View File

@ -57,8 +57,18 @@ class UserOnlySignalProcessor(signals.BaseSignalProcessor):
models.signals.post_delete.disconnect(self.handle_delete, sender=User)
class BigCharFieldIndex(indexes.CharField):
"""
Workaround to avoid xapian.InvalidArgument: Term too long (> 245)
See https://groups.google.com/forum/#!topic/django-haystack/hRJKcPNPXqw/discussion
"""
def prepare(self, term):
return super(BigCharFieldIndex, self).prepare(term)[:245]
class ForumMessageIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
text = BigCharFieldIndex(document=True, use_template=True)
auto = indexes.EdgeNgramField(use_template=True)
def get_model(self):