]> git.cworth.org Git - sup/commitdiff
xapian: drop excessively long terms
authorRich Lane <rlane@club.cc.cmu.edu>
Sat, 1 Aug 2009 22:56:09 +0000 (15:56 -0700)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Mon, 3 Aug 2009 18:05:09 +0000 (14:05 -0400)
lib/sup/xapian_index.rb

index 6358a20ca4a463682597199ec94acb5ae0e3b374..5a5dfc1225f1580019fe6a8ff032113a7e364b0f 100644 (file)
@@ -304,6 +304,8 @@ class XapianIndex < BaseIndex
 
   DATE_VALUENO = 0
 
+  MAX_TERM_LENGTH = 245
+
   # Xapian can very efficiently sort in ascending docid order. Sup always wants
   # to sort by descending date, so this method maps between them. In order to
   # handle multiple messages per second, we use a logistic curve centered
@@ -428,7 +430,7 @@ class XapianIndex < BaseIndex
 
     @term_generator.document = doc
     text.each { |text,prefix| @term_generator.index_text text, 1, prefix }
-    terms.each { |term| doc.add_term term }
+    terms.each { |term| doc.add_term term if term.length <= MAX_TERM_LENGTH }
     doc.add_value DATE_VALUENO, date_value
     doc.data = m.id