aboutsummaryrefslogtreecommitdiffhomepage
path: root/database.cc
diff options
context:
space:
mode:
authorGravatar Carl Worth <cworth@cworth.org>2009-10-21 00:35:56 -0700
committerGravatar Carl Worth <cworth@cworth.org>2009-10-21 00:35:56 -0700
commit65baa4f4e7fc401e5af742b491a3bc0784f2cdf7 (patch)
tree97bfd13076c076431f779d7296f96b1df71e49f8 /database.cc
parent6a3b68edeffa53c3e1c9aa156eff46c5999077c5 (diff)
notmuch dump: Fix the sorting of results.
To properly support sorting in notmuch_query we know use an Enquire object. We also throw in a QueryParser too, so we're really close to being able to support arbitrary full-text searches. I took a look at the supported QueryParser syntax and chose a set of flags for everything I like, (such as supporting Boolean operators in either case ("AND" or "and"), supporting phrase searching, supporting + and - to include/preclude terms, and supporting a trailing * on any term as a wildcard).
Diffstat (limited to 'database.cc')
-rw-r--r--database.cc13
1 files changed, 4 insertions, 9 deletions
diff --git a/database.cc b/database.cc
index 1c1e590b..31afe7cc 100644
--- a/database.cc
+++ b/database.cc
@@ -67,15 +67,6 @@ prefix_t BOOLEAN_PREFIX[] = {
{ "ref", "R" }
};
-/* Similarly, these value numbers are also chosen to be sup
- * compatible. */
-
-typedef enum {
- NOTMUCH_VALUE_MESSAGE_ID = 0,
- NOTMUCH_VALUE_THREAD = 1,
- NOTMUCH_VALUE_DATE = 2
-} notmuch_value_t;
-
static const char *
find_prefix (const char *name)
{
@@ -459,6 +450,9 @@ notmuch_database_open (const char *path)
try {
notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path,
Xapian::DB_CREATE_OR_OPEN);
+ notmuch->query_parser = new Xapian::QueryParser;
+ notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
+ notmuch->query_parser->set_database (*notmuch->xapian_db);
} catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred: %s\n",
error.get_msg().c_str());
@@ -478,6 +472,7 @@ notmuch_database_open (const char *path)
void
notmuch_database_close (notmuch_database_t *notmuch)
{
+ delete notmuch->query_parser;
delete notmuch->xapian_db;
free (notmuch->path);
free (notmuch);