Skip to content

Instantly share code, notes, and snippets.

@martinsam
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save martinsam/2366cea76de060ffcc4b to your computer and use it in GitHub Desktop.

Select an option

Save martinsam/2366cea76de060ffcc4b to your computer and use it in GitHub Desktop.
Patch for xapian.InvalidArgumentError: Term too long (> 245):
def split_word(word, length=230):
return (word[n:n+length] for n in range(0, len(word), length))
def prepare_YOUR_FIELD(self, obj):
return u' '.join(item for word in obj.YOUR_FIELD.split() for item in split_word(word))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment