diff options
author | Carl Worth <cworth@cworth.org> | 2009-10-28 10:42:07 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-10-28 12:50:10 -0700 |
commit | f9bbd7baa07110c7f345c8413e2426d00382cb1c (patch) | |
tree | 4669ed380656bfd23b8203d4fa93601e8dd4e553 /message.cc | |
parent | b04cc337388ea93cdd8a569a87f8bdc442f0cb33 (diff) |
Add full-text indexing using the GMime library for parsing.
This is based on the old notmuch-index-message.cc from early in
the history of notmuch, but considerably cleaned up now that
we have some experience with Xapian and know just what we want
to index, (rather than just blindly trying to index exactly
what sup does).
This does slow down notmuch_database_add_message a *lot*, but I've
got some ideas for getting some time back.
Diffstat (limited to 'message.cc')
-rw-r--r-- | message.cc | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -442,6 +442,32 @@ _notmuch_message_add_term (notmuch_message_t *message, return NOTMUCH_PRIVATE_STATUS_SUCCESS; } +/* Parse 'text' and add a term to 'message' for each parsed word. Each + * term will be added both prefixed (if prefix_name is not NULL) and + * also unprefixed). */ +notmuch_private_status_t +_notmuch_message_gen_terms (notmuch_message_t *message, + const char *prefix_name, + const char *text) +{ + Xapian::TermGenerator *term_gen = message->notmuch->term_gen; + + if (text == NULL) + return NOTMUCH_PRIVATE_STATUS_NULL_POINTER; + + term_gen->set_document (message->doc); + + if (prefix_name) { + const char *prefix = _find_prefix (prefix_name); + + term_gen->index_text (text, 1, prefix); + } + + term_gen->index_text (text); + + return NOTMUCH_PRIVATE_STATUS_SUCCESS; +} + /* Remove a name:value term from 'message', (the actual term will be * encoded by prefixing the value with a short prefix). See * NORMAL_PREFIX and BOOLEAN_PREFIX arrays for the mapping of term |