diff options
author | Carl Worth <cworth@cworth.org> | 2009-11-23 16:58:35 +0100 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2009-11-23 17:17:08 +0100 |
commit | 793cbf80495b8230e0b4de6ac609e2ca88b7dd4b (patch) | |
tree | 0847466d390d9ebf5ec63cc5a0c638a096de40d9 /lib/database.cc | |
parent | a378dff8a1b9136c3a2472dc6a88911ca3fa41b4 (diff) |
Add rudimentary date-based search.
The rudimentary aspect here is that the date ranges are specified with
UNIX timestamp values (number of seconds since 1970-01-01 UTC). One
thing that can help here is using the date program to determins
timestamps, such as:
$(date +%s -d 2009-10-01)..$(date +%s)
Long-term, we'll probably need to do our own query parsing to be able
to support directly-specified dates and also relative expressions like
"since:'2 months ago'".
Diffstat (limited to 'lib/database.cc')
-rw-r--r-- | lib/database.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/database.cc b/lib/database.cc index 2c90019..3fe12dd 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -501,11 +501,13 @@ notmuch_database_open (const char *path, notmuch->query_parser = new Xapian::QueryParser; notmuch->term_gen = new Xapian::TermGenerator; notmuch->term_gen->set_stemmer (Xapian::Stem ("english")); + notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor (NOTMUCH_VALUE_TIMESTAMP); notmuch->query_parser->set_default_op (Xapian::Query::OP_AND); notmuch->query_parser->set_database (*notmuch->xapian_db); notmuch->query_parser->set_stemmer (Xapian::Stem ("english")); notmuch->query_parser->set_stemming_strategy (Xapian::QueryParser::STEM_SOME); + notmuch->query_parser->add_valuerangeprocessor (notmuch->value_range_processor); for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX_EXTERNAL); i++) { prefix_t *prefix = &BOOLEAN_PREFIX_EXTERNAL[i]; @@ -548,6 +550,7 @@ notmuch_database_close (notmuch_database_t *notmuch) delete notmuch->term_gen; delete notmuch->query_parser; delete notmuch->xapian_db; + delete notmuch->value_range_processor; talloc_free (notmuch); } |