From 3da458ab108ae31c846fb2aeb3efe67e0d9ae925 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Mon, 22 Aug 2011 18:26:13 +0000 Subject: Don't index terms longer than the hardcoded Xapian limit Xapian has a hardcoded limit of 245 characters for terms. --- diff --git a/gdatastore/index.py b/gdatastore/index.py index 616eb81..5730f54 100644 --- a/gdatastore/index.py +++ b/gdatastore/index.py @@ -108,10 +108,12 @@ class TermGenerator(xapian.TermGenerator): elif not isinstance(value, str): value = str(value) - # We need to add the full value (i.e. not split into words), too, so - # we can enumerate unique values. It also simplifies setting up - # dictionary-based queries. - self._document.add_term(_PREFIX_FULL_VALUE + prefix + value) + # Hardcoded Xapian term length limit + if len(prefix + value) < 240: + # We need to add the full value (i.e. not split into words), too, + # so we can enumerate unique values. It also simplifies setting up + # dictionary-based queries. + self._document.add_term(_PREFIX_FULL_VALUE + prefix + value) self.index_text(value, 1, prefix) self.increase_termpos() -- cgit v0.9.1