super
@index_mutex = Monitor.new
+ end
- @entries = MarshalledGDBM.new File.join(dir, "entries.db")
- @docids = MarshalledGDBM.new File.join(dir, "docids.db")
- @thread_members = MarshalledGDBM.new File.join(dir, "thread_members.db")
- @thread_ids = MarshalledGDBM.new File.join(dir, "thread_ids.db")
- @assigned_docids = GDBM.new File.join(dir, "assigned_docids.db")
+ def load_index
+ @entries = MarshalledGDBM.new File.join(@dir, "entries.db")
+ @docids = MarshalledGDBM.new File.join(@dir, "docids.db")
+ @thread_members = MarshalledGDBM.new File.join(@dir, "thread_members.db")
+ @thread_ids = MarshalledGDBM.new File.join(@dir, "thread_ids.db")
+ @assigned_docids = GDBM.new File.join(@dir, "assigned_docids.db")
- @xapian = Xapian::WritableDatabase.new(File.join(dir, "xapian"), Xapian::DB_CREATE_OR_OPEN)
+ @xapian = Xapian::WritableDatabase.new(File.join(@dir, "xapian"), Xapian::DB_CREATE_OR_OPEN)
@term_generator = Xapian::TermGenerator.new()
@term_generator.stemmer = Xapian::Stem.new(STEM_LANGUAGE)
@enquire = Xapian::Enquire.new @xapian
@enquire.docid_order = Xapian::Enquire::ASCENDING
end
- def load_index
- end
-
def save_index
end
m
end
+ def add_message m; sync_message m end
+ def update_message m; sync_message m end
+ def update_message_state m; sync_message m end
+
def sync_message m, opts={}
entry = synchronize { @entries[m.id] }
snippet = m.snippet
:source_info => m.source_info,
:date => (entry[:date] || m.date),
:snippet => snippet,
- :labels => labels.uniq,
+ :labels => labels,
:from => (entry[:from] || [m.from.email, m.from.name]),
:to => (entry[:to] || m.to.map { |p| [p.email, p.name] }),
:cc => (entry[:cc] || m.cc.map { |p| [p.email, p.name] }),
:replytos => (entry[:replytos] || m.replytos),
}
- m.labels.each { |l| LabelManager << l }
+ labels.each { |l| LabelManager << l }
synchronize do
index_message m, opts
end
true
end
+ private :sync_message
def num_results_for query={}
xapian_query = build_xapian_query query
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
@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